Allow changing of the output geometry
authorLasse Holmstedt <lasse.holmstedt@nokia.com>
Tue, 6 Sep 2011 14:49:03 +0000 (16:49 +0200)
committerLasse Holmstedt <lasse.holmstedt@nokia.com>
Wed, 7 Sep 2011 12:18:29 +0000 (14:18 +0200)
If you are building a compositor that does not provide the same
composition area as the desktop resolution, you can now change the
geometry to match the area that your compositor is going to render.

You must set the geometry to desired value before clients connect.

Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/qt-compositor/compositor_api/waylandcompositor.cpp
src/qt-compositor/compositor_api/waylandcompositor.h
src/qt-compositor/wayland_wrapper/wlcompositor.cpp
src/qt-compositor/wayland_wrapper/wlcompositor.h
src/qt-compositor/wayland_wrapper/wloutput.cpp
src/qt-compositor/wayland_wrapper/wloutput.h

index 746ac57..ee3e949 100644 (file)
@@ -146,3 +146,8 @@ void WaylandCompositor::setScreenOrientation(qint32 orientationInDegrees)
 {
     m_compositor->setScreenOrientation(orientationInDegrees);
 }
+
+void WaylandCompositor::setOutputGeometry(const QRect &geometry)
+{
+    m_compositor->setOutputGeometry(geometry);
+}
index 71ef657..1075265 100644 (file)
@@ -85,6 +85,7 @@ public:
     const char *socketName() const;
 
     void setScreenOrientation(qint32 orientationInDegrees);
+    void setOutputGeometry(const QRect &outputGeometry);
 
 private:
     static void retainedSelectionChanged(QMimeData *mimeData, void *param);
index f76701e..032e14d 100644 (file)
@@ -456,6 +456,11 @@ void Compositor::setScreenOrientation(qint32 orientationInDegrees)
     }
 }
 
+void Compositor::setOutputGeometry(const QRect &geometry)
+{
+    m_output.setGeometry(geometry);
+}
+
 } // namespace Wayland
 
 wl_input_device * Wayland::Compositor::defaultInputDevice()
index 39404bc..647bdf6 100644 (file)
@@ -108,6 +108,7 @@ public:
     QList<struct wl_client *> clients() const;
 
     void setScreenOrientation(qint32 orientationInDegrees);
+    void setOutputGeometry(const QRect &geometry);
 
 signals:
     void clientAdded(wl_client *client);
index 6e7ea2d..39bf7c9 100644 (file)
@@ -50,7 +50,7 @@ void output_post_geometry(struct wl_client *client, struct wl_object *global, ui
     Q_UNUSED(version);
     Output *output = wayland_cast<Output *>(global);
 
-    wl_client_post_event(client, global, WL_OUTPUT_GEOMETRY, 0, 0,
+    wl_client_post_event(client, global, WL_OUTPUT_GEOMETRY, output->x(), output->y(),
                          output->size().width(), output->size().height(),0,"","");
 
     wl_client_post_event(client,global,WL_OUTPUT_MODE, 0,output->size().width(),output->size().height());
@@ -58,10 +58,16 @@ void output_post_geometry(struct wl_client *client, struct wl_object *global, ui
 
 
 Output::Output()
-    : m_size(QApplication::desktop()->screenGeometry().size())
+    : m_geometry(QPoint(0,0), QApplication::desktop()->screenGeometry().size())
     , m_displayId(-1)
     , m_numQueued(0)
 {
+
 }
 
+void Output::setGeometry(const QRect &geometry)
+{
+    m_geometry = geometry;
 }
+
+} // namespace Wayland
index cd899a5..cf64955 100644 (file)
@@ -43,7 +43,7 @@
 
 #include "waylandobject.h"
 
-#include <QtCore/QSize>
+#include <QtCore/QRect>
 
 namespace Wayland {
 
@@ -52,10 +52,14 @@ class Output : public Object<struct wl_object>
 public:
     Output();
 
-    QSize size() const { return m_size; }
+    void setGeometry(const QRect &geometry);
+
+    int x() const { return m_geometry.x(); }
+    int y() const { return m_geometry.y(); }
+    QSize size() const { return m_geometry.size(); }
 
 private:
-    QSize m_size;
+    QRect m_geometry;
     int m_displayId;
     int m_numQueued;
 };