From: Laszlo Agocs Date: Fri, 13 Apr 2012 10:58:05 +0000 (+0300) Subject: Decorations: Make it possible to move windows with transient parent X-Git-Tag: TIZEN~76 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=56758f210dc090d9b306d20c221fdc35f3b3a917;p=profile%2Fivi%2Fqtwayland.git Decorations: Make it possible to move windows with transient parent This was not working previously due to not updating the offset. Change-Id: I0a8db17a1eabeb6139129386675b271f9e1b8f22 Reviewed-by: Jørgen Lind --- diff --git a/src/compositor/wayland_wrapper/wlshellsurface.cpp b/src/compositor/wayland_wrapper/wlshellsurface.cpp index 9e37a33..4751250 100644 --- a/src/compositor/wayland_wrapper/wlshellsurface.cpp +++ b/src/compositor/wayland_wrapper/wlshellsurface.cpp @@ -116,13 +116,13 @@ void ShellSurface::adjustPosInResize() surface()->setPos(newPos); } -void ShellSurface::adjustPosToTransientParent() +QPointF ShellSurface::adjustedPosToTransientParent() const { if (!m_transientParent || (m_surface->subSurface() && m_surface->subSurface()->parent())) - return; + return m_surface->nonAdjustedPos(); - m_surface->setPos(m_transientParent->surface()->pos() + QPoint(m_xOffset,m_yOffset)); + return m_transientParent->surface()->pos() + QPoint(m_xOffset,m_yOffset); } void ShellSurface::resetResizeGrabber() @@ -140,6 +140,11 @@ ShellSurface *ShellSurface::transientParent() const return m_transientParent; } +void ShellSurface::setOffset(const QPointF &offset) +{ + m_xOffset = offset.x(); + m_yOffset = offset.y(); +} void ShellSurface::move(struct wl_client *client, struct wl_resource *shell_surface_resource, @@ -393,6 +398,8 @@ void ShellSurfaceMoveGrabber::motion(wl_pointer_grab *grab, uint32_t time, int32 QPointF pos(input_device->base()->x - shell_surface_grabber->offset_x, input_device->base()->y - shell_surface_grabber->offset_y); shell_surface->surface()->setPos(pos); + if (shell_surface->transientParent()) + shell_surface->setOffset(pos - shell_surface->transientParent()->surface()->pos()); shell_surface->surface()->damage(QRect(QPoint(0,0),shell_surface->surface()->size())); } diff --git a/src/compositor/wayland_wrapper/wlshellsurface.h b/src/compositor/wayland_wrapper/wlshellsurface.h index dc64914..1cdb6f4 100644 --- a/src/compositor/wayland_wrapper/wlshellsurface.h +++ b/src/compositor/wayland_wrapper/wlshellsurface.h @@ -44,6 +44,7 @@ #include "waylandobject.h" #include +#include namespace Wayland { @@ -78,11 +79,13 @@ public: Surface *surface() const; void adjustPosInResize(); - void adjustPosToTransientParent(); + QPointF adjustedPosToTransientParent() const; void resetResizeGrabber(); void resetMoveGrabber(); ShellSurface *transientParent() const; + void setOffset(const QPointF &offset); + private: struct wl_resource *m_shellSurface; Surface *m_surface; diff --git a/src/compositor/wayland_wrapper/wlsurface.cpp b/src/compositor/wayland_wrapper/wlsurface.cpp index 7afed8d..091f059 100644 --- a/src/compositor/wayland_wrapper/wlsurface.cpp +++ b/src/compositor/wayland_wrapper/wlsurface.cpp @@ -146,9 +146,11 @@ bool Surface::visible() const QPointF Surface::pos() const { - if (m_shellSurface) { - m_shellSurface->adjustPosToTransientParent(); - } + return m_shellSurface ? m_shellSurface->adjustedPosToTransientParent() : m_position; +} + +QPointF Surface::nonAdjustedPos() const +{ return m_position; } diff --git a/src/compositor/wayland_wrapper/wlsurface.h b/src/compositor/wayland_wrapper/wlsurface.h index cd06959..95377b5 100644 --- a/src/compositor/wayland_wrapper/wlsurface.h +++ b/src/compositor/wayland_wrapper/wlsurface.h @@ -85,6 +85,7 @@ public: uint id() const { return base()->resource.object.id; } QPointF pos() const; + QPointF nonAdjustedPos() const; void setPos(const QPointF &pos); QSize size() const;