summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2012-02-13 20:39:22 +0100
committerJørgen Lind <jorgen.lind@nokia.com>2012-02-14 09:55:02 +0100
commit2ed43741ab4106c6a1e9eb3a5cb9a6c5ff34f450 (patch)
tree305297d6f665d3f43ef131f5f5577262fa325303 /src
parentb61d1417dc81761276b3bac44775141b3551ef4e (diff)
downloadqtwayland-2ed43741ab4106c6a1e9eb3a5cb9a6c5ff34f450.tar.gz
Added convenience properties in WaylandSurface for window orientation.
The new windowRotation property is especially useful for the compositor to know how much the surface needs to be rotated in order to be displayed correctly. Change-Id: I81ee17880ceafd465c39b4439dee978f2cb80924 Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/compositor/compositor_api/waylandcompositor.cpp5
-rw-r--r--src/compositor/compositor_api/waylandcompositor.h2
-rw-r--r--src/compositor/compositor_api/waylandsurface.cpp22
-rw-r--r--src/compositor/compositor_api/waylandsurface.h7
-rw-r--r--src/compositor/compositor_api/waylandsurfaceitem.cpp6
-rw-r--r--src/compositor/compositor_api/waylandsurfaceitem.h3
-rw-r--r--src/compositor/wayland_wrapper/wlcompositor.cpp5
-rw-r--r--src/compositor/wayland_wrapper/wlcompositor.h1
-rw-r--r--src/compositor/wayland_wrapper/wlextendedsurface.cpp8
-rw-r--r--src/compositor/wayland_wrapper/wloutput.h1
10 files changed, 58 insertions, 2 deletions
diff --git a/src/compositor/compositor_api/waylandcompositor.cpp b/src/compositor/compositor_api/waylandcompositor.cpp
index b1388cbe..9196a574 100644
--- a/src/compositor/compositor_api/waylandcompositor.cpp
+++ b/src/compositor/compositor_api/waylandcompositor.cpp
@@ -157,6 +157,11 @@ void WaylandCompositor::setOutputGeometry(const QRect &geometry)
m_compositor->setOutputGeometry(geometry);
}
+QRect WaylandCompositor::outputGeometry() const
+{
+ return m_compositor->outputGeometry();
+}
+
WaylandInputDevice *WaylandCompositor::defaultInputDevice() const
{
return m_compositor->defaultInputDevice()->handle();
diff --git a/src/compositor/compositor_api/waylandcompositor.h b/src/compositor/compositor_api/waylandcompositor.h
index 3cc255a8..22072659 100644
--- a/src/compositor/compositor_api/waylandcompositor.h
+++ b/src/compositor/compositor_api/waylandcompositor.h
@@ -82,7 +82,9 @@ public:
const char *socketName() const;
void setScreenOrientation(Qt::ScreenOrientation orientation);
+
void setOutputGeometry(const QRect &outputGeometry);
+ QRect outputGeometry() const;
WaylandInputDevice *defaultInputDevice() const;
diff --git a/src/compositor/compositor_api/waylandsurface.cpp b/src/compositor/compositor_api/waylandsurface.cpp
index e9be748c..7effff05 100644
--- a/src/compositor/compositor_api/waylandsurface.cpp
+++ b/src/compositor/compositor_api/waylandsurface.cpp
@@ -47,8 +47,12 @@
#include "wayland_wrapper/wlsubsurface.h"
#include "wayland_wrapper/wlcompositor.h"
+#include "waylandcompositor.h"
#include "waylandwindowmanagerintegration.h"
+#include <QtGui/QGuiApplication>
+#include <QtGui/QScreen>
+
#ifdef QT_COMPOSITOR_QUICK
#include "waylandsurfaceitem.h"
#endif
@@ -80,7 +84,7 @@ public:
WaylandSurface::WaylandSurface(Wayland::Surface *surface)
: QObject(*new WaylandSurfacePrivate(surface))
{
-
+ connect(this, SIGNAL(windowOrientationChanged()), this, SIGNAL(windowRotationChanged()));
}
WaylandSurface *WaylandSurface::parentSurface() const
@@ -159,7 +163,23 @@ Qt::ScreenOrientation WaylandSurface::windowOrientation() const
return d->surface->extendedSurface()->windowOrientation();
}
+/*!
+ \property windowRotation
+
+ Convenience property to get the rotation required to map the surface to the screen
+ based on its windowOrientation.
+ */
+int WaylandSurface::windowRotation() const
+{
+ QRect geometry = compositor()->outputGeometry();
+ Qt::ScreenOrientation compositorOrientation = geometry.width() >= geometry.height() ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
+ Qt::ScreenOrientation wOrientation = windowOrientation();
+ if (wOrientation == Qt::PrimaryOrientation)
+ return 0;
+
+ return QGuiApplication::primaryScreen()->angleBetween(wOrientation, compositorOrientation);
+}
WaylandSurface::WindowFlags WaylandSurface::windowFlags() const
{
diff --git a/src/compositor/compositor_api/waylandsurface.h b/src/compositor/compositor_api/waylandsurface.h
index 83490661..40b87017 100644
--- a/src/compositor/compositor_api/waylandsurface.h
+++ b/src/compositor/compositor_api/waylandsurface.h
@@ -73,6 +73,9 @@ class Q_COMPOSITOR_EXPORT WaylandSurface : public QObject
Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY sizeChanged)
Q_PROPERTY(QPointF pos READ pos WRITE setPos NOTIFY posChanged)
Q_PROPERTY(WaylandSurface::WindowFlags windowFlags READ windowFlags NOTIFY windowFlagsChanged)
+ 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_ENUMS(WindowFlag)
Q_FLAGS(WindowFlag WindowFlags)
@@ -107,6 +110,7 @@ public:
Qt::ScreenOrientation contentOrientation() const;
Qt::ScreenOrientation windowOrientation() const;
+ int windowRotation() const;
WindowFlags windowFlags() const;
@@ -147,6 +151,9 @@ signals:
void posChanged();
void windowPropertyChanged(const QString &name, const QVariant &value);
void windowFlagsChanged(WindowFlags flags);
+ void windowOrientationChanged();
+ void contentOrientationChanged();
+ void windowRotationChanged();
friend class Wayland::Surface;
friend class Wayland::SurfacePrivate;
diff --git a/src/compositor/compositor_api/waylandsurfaceitem.cpp b/src/compositor/compositor_api/waylandsurfaceitem.cpp
index a080f836..9418b429 100644
--- a/src/compositor/compositor_api/waylandsurfaceitem.cpp
+++ b/src/compositor/compositor_api/waylandsurfaceitem.cpp
@@ -47,6 +47,8 @@
#include "wlextendedsurface.h"
#include <QtGui/QKeyEvent>
+#include <QtGui/QGuiApplication>
+#include <QtGui/QScreen>
#include <QtQuick/QSGSimpleTextureNode>
#include <QtQuick/QSGSimpleRectNode>
@@ -130,7 +132,11 @@ WaylandSurfaceItem::~WaylandSurfaceItem()
void WaylandSurfaceItem::setSurface(WaylandSurface *surface)
{
+ if (surface == m_surface)
+ return;
+
init(surface);
+ emit surfaceChanged();
}
bool WaylandSurfaceItem::isYInverted() const
diff --git a/src/compositor/compositor_api/waylandsurfaceitem.h b/src/compositor/compositor_api/waylandsurfaceitem.h
index 73697ae2..0114f127 100644
--- a/src/compositor/compositor_api/waylandsurfaceitem.h
+++ b/src/compositor/compositor_api/waylandsurfaceitem.h
@@ -56,7 +56,7 @@ Q_DECLARE_METATYPE(WaylandSurface*)
class Q_COMPOSITOR_EXPORT WaylandSurfaceItem : public QQuickItem
{
Q_OBJECT
- Q_PROPERTY(WaylandSurface* surface READ surface WRITE setSurface)
+ Q_PROPERTY(WaylandSurface* surface READ surface WRITE setSurface NOTIFY surfaceChanged)
Q_PROPERTY(bool paintEnabled READ paintEnabled WRITE setPaintEnabled)
Q_PROPERTY(bool useTextureAlpha READ useTextureAlpha WRITE setUseTextureAlpha NOTIFY useTextureAlphaChanged)
Q_PROPERTY(bool clientRenderingEnabled READ clientRenderingEnabled WRITE setClientRenderingEnabled NOTIFY clientRenderingEnabledChanged)
@@ -114,6 +114,7 @@ signals:
void clientRenderingEnabledChanged();
void touchEventsEnabledChanged();
void yInvertedChanged();
+ void surfaceChanged();
protected:
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *);
diff --git a/src/compositor/wayland_wrapper/wlcompositor.cpp b/src/compositor/wayland_wrapper/wlcompositor.cpp
index 545d14e3..27378f19 100644
--- a/src/compositor/wayland_wrapper/wlcompositor.cpp
+++ b/src/compositor/wayland_wrapper/wlcompositor.cpp
@@ -360,6 +360,11 @@ void Compositor::setOutputGeometry(const QRect &geometry)
m_output_global.setGeometry(geometry);
}
+QRect Compositor::outputGeometry() const
+{
+ return m_output_global.geometry();
+}
+
InputDevice* Compositor::defaultInputDevice()
{
return m_default_input_device;
diff --git a/src/compositor/wayland_wrapper/wlcompositor.h b/src/compositor/wayland_wrapper/wlcompositor.h
index 03cd1db5..b2d4ef6e 100644
--- a/src/compositor/wayland_wrapper/wlcompositor.h
+++ b/src/compositor/wayland_wrapper/wlcompositor.h
@@ -117,6 +117,7 @@ public:
void setScreenOrientation(Qt::ScreenOrientation orientation);
Qt::ScreenOrientation screenOrientation() const;
void setOutputGeometry(const QRect &geometry);
+ QRect outputGeometry() const;
void enableTouchExtension();
TouchExtensionGlobal *touchExtension() { return m_touchExtension; }
diff --git a/src/compositor/wayland_wrapper/wlextendedsurface.cpp b/src/compositor/wayland_wrapper/wlextendedsurface.cpp
index c5bde258..e4dd6bf4 100644
--- a/src/compositor/wayland_wrapper/wlextendedsurface.cpp
+++ b/src/compositor/wayland_wrapper/wlextendedsurface.cpp
@@ -154,7 +154,11 @@ void ExtendedSurface::set_window_orientation(struct wl_client *client,
{
Q_UNUSED(client);
ExtendedSurface *extended_surface = static_cast<ExtendedSurface *>(extended_surface_resource->data);
+
+ Qt::ScreenOrientation oldOrientation = extended_surface->m_windowOrientation;
extended_surface->m_windowOrientation = screenOrientationFromWaylandOrientation(orientation);
+ if (extended_surface->m_windowOrientation != oldOrientation)
+ emit extended_surface->m_surface->waylandSurface()->windowOrientationChanged();
}
void ExtendedSurface::set_content_orientation(struct wl_client *client,
@@ -163,7 +167,11 @@ void ExtendedSurface::set_content_orientation(struct wl_client *client,
{
Q_UNUSED(client);
ExtendedSurface *extended_surface = static_cast<ExtendedSurface *>(extended_surface_resource->data);
+
+ Qt::ScreenOrientation oldOrientation = extended_surface->m_contentOrientation;
extended_surface->m_contentOrientation = screenOrientationFromWaylandOrientation(orientation);
+ if (extended_surface->m_windowOrientation != oldOrientation)
+ emit extended_surface->m_surface->waylandSurface()->contentOrientationChanged();
}
void ExtendedSurface::setWindowFlags(WaylandSurface::WindowFlags flags)
diff --git a/src/compositor/wayland_wrapper/wloutput.h b/src/compositor/wayland_wrapper/wloutput.h
index f678547a..b637d2d3 100644
--- a/src/compositor/wayland_wrapper/wloutput.h
+++ b/src/compositor/wayland_wrapper/wloutput.h
@@ -57,6 +57,7 @@ public:
OutputGlobal();
void setGeometry(const QRect &geometry);
+ QRect geometry() const { return m_geometry; }
int x() const { return m_geometry.x(); }
int y() const { return m_geometry.y(); }