From 9d7ef928ce0febdcee3cb4327b7f4fc559d3aba1 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 8 May 2012 12:41:30 +0300 Subject: [PATCH] Update to wayland head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: Ie012861bc40e3bc448d85c9d8c27f798434020ed Reviewed-by: Samuel Rødal --- src/compositor/compositor_api/waylandsurface.cpp | 6 ++++ src/compositor/compositor_api/waylandsurface.h | 4 +++ .../xcomposite_share/xcompositebuffer.cpp | 1 + src/compositor/wayland_wrapper/wlshellsurface.cpp | 36 ++++++++++++++++++++-- src/compositor/wayland_wrapper/wlshellsurface.h | 13 ++++++-- src/compositor/wayland_wrapper/wlsurface.cpp | 8 +++++ src/compositor/wayland_wrapper/wlsurface.h | 4 +++ .../platforms/wayland/qwaylandshellsurface.cpp | 14 +++++++++ .../platforms/wayland/qwaylandshellsurface.h | 5 +++ src/plugins/platforms/wayland/qwaylandwindow.cpp | 5 ++- tests/auto/client/mockshell.cpp | 32 ++++++++++++++++++- wayland_sha1.txt | 2 +- 12 files changed, 122 insertions(+), 8 deletions(-) diff --git a/src/compositor/compositor_api/waylandsurface.cpp b/src/compositor/compositor_api/waylandsurface.cpp index 62914e2..1b56566 100644 --- a/src/compositor/compositor_api/waylandsurface.cpp +++ b/src/compositor/compositor_api/waylandsurface.cpp @@ -324,3 +324,9 @@ void WaylandSurface::sendOnScreenVisibilityChange(bool visible) if (d->surface->extendedSurface()) d->surface->extendedSurface()->sendOnScreenVisibility(visible); } + +QString WaylandSurface::title() const +{ + Q_D(const WaylandSurface); + return d->surface->title(); +} diff --git a/src/compositor/compositor_api/waylandsurface.h b/src/compositor/compositor_api/waylandsurface.h index 53589dd..5cbc6d0 100644 --- a/src/compositor/compositor_api/waylandsurface.h +++ b/src/compositor/compositor_api/waylandsurface.h @@ -76,6 +76,7 @@ class Q_COMPOSITOR_EXPORT WaylandSurface : public QObject Q_PROPERTY(Qt::ScreenOrientation windowOrientation READ windowOrientation NOTIFY windowOrientationChanged) Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation NOTIFY contentOrientationChanged) Q_PROPERTY(int windowRotation READ windowRotation NOTIFY windowRotationChanged) + Q_PROPERTY(QString title READ title NOTIFY titleChanged) Q_ENUMS(WindowFlag) Q_FLAGS(WindowFlag WindowFlags) @@ -146,6 +147,8 @@ public: WaylandCompositor *compositor() const; + QString title() const; + signals: void mapped(); void unmapped(); @@ -159,6 +162,7 @@ signals: void contentOrientationChanged(); void windowRotationChanged(); void extendedSurfaceReady(); + void titleChanged(); }; diff --git a/src/compositor/hardware_integration/xcomposite_share/xcompositebuffer.cpp b/src/compositor/hardware_integration/xcomposite_share/xcompositebuffer.cpp index 29f6ceb..55bf9b0 100644 --- a/src/compositor/hardware_integration/xcomposite_share/xcompositebuffer.cpp +++ b/src/compositor/hardware_integration/xcomposite_share/xcompositebuffer.cpp @@ -44,6 +44,7 @@ XCompositeBuffer::XCompositeBuffer(Wayland::Compositor *compositor, Window windo : mWindow(window) , mInvertedY(false) { + Q_UNUSED(compositor); base()->height = size.height(); base()->width = size.width(); } diff --git a/src/compositor/wayland_wrapper/wlshellsurface.cpp b/src/compositor/wayland_wrapper/wlshellsurface.cpp index a89cd0a..333934e 100644 --- a/src/compositor/wayland_wrapper/wlshellsurface.cpp +++ b/src/compositor/wayland_wrapper/wlshellsurface.cpp @@ -258,14 +258,44 @@ void ShellSurface::set_maximized(struct wl_client *client, Q_UNUSED(output); } +void ShellSurface::pong(struct wl_client *client, + struct wl_resource *resource, + uint32_t serial) +{ + Q_UNUSED(client); + Q_UNUSED(resource); + Q_UNUSED(serial); +} + +void ShellSurface::set_title(struct wl_client *client, + struct wl_resource *resource, + const char *title) +{ + Q_UNUSED(client); + ShellSurface *self = static_cast(resource->data); + self->surface()->setTitle(QString::fromUtf8(title)); +} + +void ShellSurface::set_class(struct wl_client *client, + struct wl_resource *resource, + const char *class_) +{ + Q_UNUSED(client); + Q_UNUSED(resource); + Q_UNUSED(class_); +} + const struct wl_shell_surface_interface ShellSurface::shell_surface_interface = { + ShellSurface::pong, ShellSurface::move, ShellSurface::resize, ShellSurface::set_toplevel, ShellSurface::set_transient, ShellSurface::set_fullscreen, ShellSurface::set_popup, - ShellSurface::set_maximized + ShellSurface::set_maximized, + ShellSurface::set_title, + ShellSurface::set_class }; Qt::MouseButton toQtButton(uint32_t button) @@ -371,7 +401,7 @@ void ShellSurfaceResizeGrabber::motion(wl_pointer_grab *grab, uint32_t time, int shell_surface->sendConfigure(resize_grabber->resize_edges,new_width,new_height); } -void ShellSurfaceResizeGrabber::button(wl_pointer_grab *grab, uint32_t time, uint32_t button, int32_t state) +void ShellSurfaceResizeGrabber::button(wl_pointer_grab *grab, uint32_t time, uint32_t button, uint32_t state) { Q_UNUSED(time) ShellSurfaceResizeGrabber *self = reinterpret_cast(grab); @@ -418,7 +448,7 @@ void ShellSurfaceMoveGrabber::motion(wl_pointer_grab *grab, uint32_t time, int32 shell_surface->surface()->damage(QRect(QPoint(0,0),shell_surface->surface()->size())); } -void ShellSurfaceMoveGrabber::button(wl_pointer_grab *grab, uint32_t time, uint32_t button, int32_t state) +void ShellSurfaceMoveGrabber::button(wl_pointer_grab *grab, uint32_t time, uint32_t button, uint32_t state) { Q_UNUSED(time) ShellSurfaceResizeGrabber *self = reinterpret_cast(grab); diff --git a/src/compositor/wayland_wrapper/wlshellsurface.h b/src/compositor/wayland_wrapper/wlshellsurface.h index 3f8d42a..2661afe 100644 --- a/src/compositor/wayland_wrapper/wlshellsurface.h +++ b/src/compositor/wayland_wrapper/wlshellsurface.h @@ -131,6 +131,15 @@ private: static void set_maximized(struct wl_client *client, struct wl_resource *shell_surface_resource, struct wl_resource *output); + static void pong(struct wl_client *client, + struct wl_resource *resource, + uint32_t serial); + static void set_title(struct wl_client *client, + struct wl_resource *resource, + const char *title); + static void set_class(struct wl_client *client, + struct wl_resource *resource, + const char *class_); static const struct wl_shell_surface_interface shell_surface_interface; }; @@ -163,7 +172,7 @@ public: static void motion(struct wl_pointer_grab *grab, uint32_t time, int32_t x, int32_t y); static void button(struct wl_pointer_grab *grab, - uint32_t time, uint32_t mouse_grabber_button, int32_t state); + uint32_t time, uint32_t mouse_grabber_button, uint32_t state); static const struct wl_pointer_grab_interface resize_grabber_interface; }; @@ -180,7 +189,7 @@ public: static void motion(struct wl_pointer_grab *grab, uint32_t time, int32_t x, int32_t y); static void button(struct wl_pointer_grab *grab, - uint32_t time, uint32_t mouse_grabber_button, int32_t state); + uint32_t time, uint32_t mouse_grabber_button, uint32_t state); static const struct wl_pointer_grab_interface move_grabber_interface; }; diff --git a/src/compositor/wayland_wrapper/wlsurface.cpp b/src/compositor/wayland_wrapper/wlsurface.cpp index 68e58fb..a027397 100644 --- a/src/compositor/wayland_wrapper/wlsurface.cpp +++ b/src/compositor/wayland_wrapper/wlsurface.cpp @@ -475,5 +475,13 @@ void Surface::surface_set_input_region(struct wl_client *client, struct wl_resou surface->m_inputRegion = region ? resolve(region)->region() : QRegion(QRect(QPoint(), surface->size())); } +void Surface::setTitle(const QString &title) +{ + if (m_title != title) { + m_title = title; + emit waylandSurface()->titleChanged(); + } +} + } // namespace Wayland diff --git a/src/compositor/wayland_wrapper/wlsurface.h b/src/compositor/wayland_wrapper/wlsurface.h index 95377b5..0716172 100644 --- a/src/compositor/wayland_wrapper/wlsurface.h +++ b/src/compositor/wayland_wrapper/wlsurface.h @@ -123,6 +123,9 @@ public: static const struct wl_surface_interface surface_interface; + QString title() const { return m_title; } + void setTitle(const QString &title); + private: Q_DISABLE_COPY(Surface) @@ -151,6 +154,7 @@ private: QPointF m_position; QSize m_size; + QString m_title; inline SurfaceBuffer *currentSurfaceBuffer() const; bool advanceBufferQueue(); diff --git a/src/plugins/platforms/wayland/qwaylandshellsurface.cpp b/src/plugins/platforms/wayland/qwaylandshellsurface.cpp index 96c3fb2..fd8170f 100644 --- a/src/plugins/platforms/wayland/qwaylandshellsurface.cpp +++ b/src/plugins/platforms/wayland/qwaylandshellsurface.cpp @@ -88,6 +88,19 @@ void QWaylandShellSurface::updateTransientParent(QWindow *parent) 0); } +void QWaylandShellSurface::setTitle(const char *title) +{ + wl_shell_surface_set_title(m_shell_surface, title); +} + +void QWaylandShellSurface::ping(void *data, + struct wl_shell_surface *wl_shell_surface, + uint32_t serial) +{ + Q_UNUSED(data); + wl_shell_surface_pong(wl_shell_surface, serial); +} + void QWaylandShellSurface::configure(void *data, wl_shell_surface *wl_shell_surface, uint32_t edges, @@ -107,6 +120,7 @@ void QWaylandShellSurface::popup_done(void *data, } const wl_shell_surface_listener QWaylandShellSurface::m_shell_surface_listener = { + QWaylandShellSurface::ping, QWaylandShellSurface::configure, QWaylandShellSurface::popup_done }; diff --git a/src/plugins/platforms/wayland/qwaylandshellsurface.h b/src/plugins/platforms/wayland/qwaylandshellsurface.h index 148bb0e..1438773 100644 --- a/src/plugins/platforms/wayland/qwaylandshellsurface.h +++ b/src/plugins/platforms/wayland/qwaylandshellsurface.h @@ -63,10 +63,15 @@ public: struct wl_shell_surface *handle() const { return m_shell_surface; } + void setTitle(const char *title); + private: struct wl_shell_surface *m_shell_surface; QWaylandWindow *m_window; + static void ping(void *data, + struct wl_shell_surface *wl_shell_surface, + uint32_t serial); static void configure(void *data, struct wl_shell_surface *wl_shell_surface, uint32_t edges, diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index e9eadf4..c023de5 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -133,7 +133,10 @@ void QWaylandWindow::setParent(const QPlatformWindow *parent) void QWaylandWindow::setWindowTitle(const QString &title) { - Q_UNUSED(title); + if (mShellSurface) { + QByteArray titleUtf8 = title.toUtf8(); + mShellSurface->setTitle(titleUtf8.constData()); + } if (mWindowDecoration && window()->isVisible()) { mWindowDecoration->paintDecoration(); } diff --git a/tests/auto/client/mockshell.cpp b/tests/auto/client/mockshell.cpp index f11a530..cfc4390 100644 --- a/tests/auto/client/mockshell.cpp +++ b/tests/auto/client/mockshell.cpp @@ -43,6 +43,15 @@ namespace Impl { +void shell_surface_pong(wl_client *client, + wl_resource *surface_resource, + uint32_t serial) +{ + Q_UNUSED(client); + Q_UNUSED(surface_resource); + Q_UNUSED(serial); +} + void shell_surface_move(wl_client *client, wl_resource *surface_resource, wl_resource *input_device_resource, @@ -129,16 +138,37 @@ void shell_surface_set_maximized(wl_client *client, Q_UNUSED(output); } +void shell_surface_set_title(wl_client *client, + wl_resource *surface_resource, + const char *title) +{ + Q_UNUSED(client); + Q_UNUSED(surface_resource); + Q_UNUSED(title); +} + +void shell_surface_set_class(wl_client *client, + wl_resource *surface_resource, + const char *class_) +{ + Q_UNUSED(client); + Q_UNUSED(surface_resource); + Q_UNUSED(class_); +} + static void get_shell_surface(wl_client *client, wl_resource *compositorResource, uint32_t id, wl_resource *surfaceResource) { static const struct wl_shell_surface_interface shellSurfaceInterface = { + shell_surface_pong, shell_surface_move, shell_surface_resize, shell_surface_set_toplevel, shell_surface_set_transient, shell_surface_set_fullscreen, shell_surface_set_popup, - shell_surface_set_maximized + shell_surface_set_maximized, + shell_surface_set_title, + shell_surface_set_class }; Q_UNUSED(compositorResource); diff --git a/wayland_sha1.txt b/wayland_sha1.txt index 345ea77..3b2c751 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: -677c5180e67be18b7a0867fafb7f205b57a6e9ff +3f7048e0e99af50fe3555ab3f61f0ef1292959e4 -- 2.7.4