Decorations: Make it possible to move windows with transient parent
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>
Fri, 13 Apr 2012 10:58:05 +0000 (13:58 +0300)
committerJørgen Lind <jorgen.lind@nokia.com>
Tue, 17 Apr 2012 11:12:02 +0000 (13:12 +0200)
This was not working previously due to not updating the offset.

Change-Id: I0a8db17a1eabeb6139129386675b271f9e1b8f22
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
src/compositor/wayland_wrapper/wlshellsurface.cpp
src/compositor/wayland_wrapper/wlshellsurface.h
src/compositor/wayland_wrapper/wlsurface.cpp
src/compositor/wayland_wrapper/wlsurface.h

index 9e37a33..4751250 100644 (file)
@@ -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()));
 }
 
index dc64914..1cdb6f4 100644 (file)
@@ -44,6 +44,7 @@
 #include "waylandobject.h"
 
 #include <wayland-server.h>
+#include <QPoint>
 
 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;
index 7afed8d..091f059 100644 (file)
@@ -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;
 }
 
index cd06959..95377b5 100644 (file)
@@ -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;