summaryrefslogtreecommitdiffstats
path: root/src/compositor
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@theqtcompany.com>2015-01-21 10:07:25 +0100
committerJørgen Lind <jorgen.lind@theqtcompany.com>2015-08-28 13:09:41 +0200
commit7bdffe9e34c7cd071551bfe07a50811f4c7160d8 (patch)
tree866f0fffebf49683fad5ee470b965f0fb088061f /src/compositor
parent6edb553d443abf5eff1428a2a7398ac1ff826fad (diff)
QWaylandOutput send mode and geometry correctly
Diffstat (limited to 'src/compositor')
-rw-r--r--src/compositor/compositor_api/qwaylandoutput.cpp22
-rw-r--r--src/compositor/compositor_api/qwaylandoutput.h12
-rw-r--r--src/compositor/wayland_wrapper/qwloutput.cpp41
-rw-r--r--src/compositor/wayland_wrapper/qwloutput_p.h6
4 files changed, 81 insertions, 0 deletions
diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp
index 13b6f5880..8bcd9dcd7 100644
--- a/src/compositor/compositor_api/qwaylandoutput.cpp
+++ b/src/compositor/compositor_api/qwaylandoutput.cpp
@@ -58,6 +58,8 @@ QWaylandOutput::QWaylandOutput(QWaylandCompositor *compositor, QWindow *window,
d_ptr->setManufacturer(manufacturer);
d_ptr->setModel(model);
d_ptr->compositor()->addOutput(this);
+ QObject::connect(window, &QWindow::widthChanged, this, &QWaylandOutput::setWidth);
+ QObject::connect(window, &QWindow::heightChanged, this, &QWaylandOutput::setHeight);
}
QWaylandOutput::~QWaylandOutput()
@@ -233,6 +235,16 @@ void QWaylandOutput::setScaleFactor(int scale)
}
+bool QWaylandOutput::sizeFollowsWindow() const
+{
+ return d_ptr->sizeFollowsWindow();
+}
+
+void QWaylandOutput::setSizeFollowsWindow(bool follow)
+{
+ d_ptr->setSizeFollowsWindow(follow);
+}
+
QWindow *QWaylandOutput::window() const
{
return d_ptr->window();
@@ -273,4 +285,14 @@ QtWayland::Output *QWaylandOutput::handle() const
return d_ptr.data();
}
+void QWaylandOutput::setWidth(int newWidth)
+{
+ d_ptr->setWidth(newWidth);
+}
+
+void QWaylandOutput::setHeight(int newHeight)
+{
+ d_ptr->setHeight(newHeight);
+}
+
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandoutput.h b/src/compositor/compositor_api/qwaylandoutput.h
index adaf0f188..5314aa412 100644
--- a/src/compositor/compositor_api/qwaylandoutput.h
+++ b/src/compositor/compositor_api/qwaylandoutput.h
@@ -72,7 +72,9 @@ class Q_COMPOSITOR_EXPORT QWaylandOutput : public QObject
Q_PROPERTY(int scaleFactor READ scaleFactor WRITE setScaleFactor NOTIFY scaleFactorChanged)
Q_PROPERTY(QWaylandCompositor *compositor READ compositor CONSTANT)
Q_PROPERTY(QWindow *window READ window CONSTANT)
+ Q_PROPERTY(bool sizeFollowsWindow READ sizeFollowsWindow WRITE setSizeFollowsWindow NOTIFY sizeFollowsWindowChanged)
Q_ENUMS(Subpixel Transform)
+
public:
enum Subpixel {
SubpixelUnknown = 0,
@@ -122,6 +124,8 @@ public:
QRect geometry() const;
void setGeometry(const QRect &geometry);
+ void setWidth(int newWidth);
+ void setHeight(int newHeight);
QRect availableGeometry() const;
void setAvailableGeometry(const QRect &availableGeometry);
@@ -140,6 +144,12 @@ public:
QWindow *window() const;
+ bool sizeFollowsWindow() const;
+ void setSizeFollowsWindow(bool follow);
+
+ bool physicalSizeFollowsSize() const;
+ void setPhysicalSizeFollowsSize(bool follow);
+
void frameStarted();
void sendFrameCallbacks(QList<QWaylandSurface *> visibleSurfaces);
@@ -159,6 +169,8 @@ Q_SIGNALS:
void scaleFactorChanged();
void subpixelChanged();
void transformChanged();
+ void sizeFollowsWindowChanged();
+ void physicalSizeFollowsSizeChanged();
protected:
QScopedPointer<QtWayland::Output> d_ptr;
diff --git a/src/compositor/wayland_wrapper/qwloutput.cpp b/src/compositor/wayland_wrapper/qwloutput.cpp
index 1a80ab033..1ff52ad5f 100644
--- a/src/compositor/wayland_wrapper/qwloutput.cpp
+++ b/src/compositor/wayland_wrapper/qwloutput.cpp
@@ -109,6 +109,7 @@ Output::Output(Compositor *compositor, QWindow *window)
, m_subpixel(QWaylandOutput::SubpixelUnknown)
, m_transform(QWaylandOutput::TransformNormal)
, m_scaleFactor(1)
+ , m_sizeFollowsWindow(true)
{
m_mode.size = window ? window->size() : QSize();
m_mode.refreshRate = 60;
@@ -175,6 +176,26 @@ QRect Output::geometry() const
return QRect(m_position, m_mode.size);
}
+bool Output::sizeFollowsWindow() const
+{
+ return m_sizeFollowsWindow;
+}
+
+void Output::setSizeFollowsWindow(bool follow)
+{
+ if (follow != m_sizeFollowsWindow) {
+ if (follow) {
+ QObject::connect(m_window, &QWindow::widthChanged, m_output, &QWaylandOutput::setWidth);
+ QObject::connect(m_window, &QWindow::heightChanged, m_output, &QWaylandOutput::setHeight);
+ } else {
+ QObject::disconnect(m_window, &QWindow::widthChanged, m_output, &QWaylandOutput::setWidth);
+ QObject::disconnect(m_window, &QWindow::heightChanged, m_output, &QWaylandOutput::setHeight);
+ }
+ m_sizeFollowsWindow = follow;
+ m_output->sizeFollowsWindowChanged();
+ }
+}
+
void Output::setGeometry(const QRect &geometry)
{
if (m_position == geometry.topLeft() && m_mode.size == geometry.size())
@@ -197,6 +218,26 @@ void Output::setGeometry(const QRect &geometry)
}
}
+void Output::setWidth(int newWidth)
+{
+ if (m_mode.size.width() == newWidth)
+ return;
+
+ QSize s = m_mode.size;
+ s.setWidth(newWidth);
+ setGeometry(QRect(m_position, s));
+}
+
+void Output::setHeight(int newHeight)
+{
+ if (m_mode.size.height() == newHeight)
+ return;
+
+ QSize s = m_mode.size;
+ s.setHeight(newHeight);
+ setGeometry(QRect(m_position, s));
+}
+
void Output::setAvailableGeometry(const QRect &availableGeometry)
{
m_availableGeometry = availableGeometry;
diff --git a/src/compositor/wayland_wrapper/qwloutput_p.h b/src/compositor/wayland_wrapper/qwloutput_p.h
index ee6a34262..18c3801a5 100644
--- a/src/compositor/wayland_wrapper/qwloutput_p.h
+++ b/src/compositor/wayland_wrapper/qwloutput_p.h
@@ -79,6 +79,11 @@ public:
QRect geometry() const;
void setGeometry(const QRect &geometry);
+ void setWidth(int newWidth);
+ void setHeight(int newHeight);
+
+ bool sizeFollowsWindow() const;
+ void setSizeFollowsWindow(bool follow);
QWaylandOutput::Mode mode() const { return m_mode; }
void setMode(const QWaylandOutput::Mode &mode);
@@ -131,6 +136,7 @@ private:
QWaylandOutput::Transform m_transform;
int m_scaleFactor;
QList<QWaylandSurface *> m_surfaces;
+ bool m_sizeFollowsWindow;
void sendGeometryInfo();
};