summaryrefslogtreecommitdiffstats
path: root/tests/auto/client/shared
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/client/shared')
-rw-r--r--tests/auto/client/shared/corecompositor.cpp2
-rw-r--r--tests/auto/client/shared/coreprotocol.cpp39
-rw-r--r--tests/auto/client/shared/coreprotocol.h49
-rw-r--r--tests/auto/client/shared/mockcompositor.cpp3
-rw-r--r--tests/auto/client/shared/mockcompositor.h1
5 files changed, 81 insertions, 13 deletions
diff --git a/tests/auto/client/shared/corecompositor.cpp b/tests/auto/client/shared/corecompositor.cpp
index afa25e94c..7edb1c2d4 100644
--- a/tests/auto/client/shared/corecompositor.cpp
+++ b/tests/auto/client/shared/corecompositor.cpp
@@ -97,8 +97,8 @@ void CoreCompositor::add(Global *global)
void CoreCompositor::remove(Global *global)
{
warnIfNotLockedByThread(Q_FUNC_INFO);
- //TODO: Need to delete global as well!
m_globals.removeAll(global);
+ delete global;
}
uint CoreCompositor::nextSerial()
diff --git a/tests/auto/client/shared/coreprotocol.cpp b/tests/auto/client/shared/coreprotocol.cpp
index 46d46d980..fdd5f627c 100644
--- a/tests/auto/client/shared/coreprotocol.cpp
+++ b/tests/auto/client/shared/coreprotocol.cpp
@@ -125,28 +125,55 @@ QString WlCompositor::dirtyMessage()
return "Dirty, surfaces left:\n\t" + messages.join("\n\t");
}
+void Output::sendGeometry()
+{
+ const auto resources = resourceMap().values();
+ for (auto r : resources)
+ sendGeometry(r);
+}
+
+void Output::sendGeometry(Resource *resource)
+{
+ // TODO: check resource version as well?
+ wl_output::send_geometry(resource->handle,
+ m_data.position.x(), m_data.position.y(),
+ m_data.physicalSize.width(), m_data.physicalSize.height(),
+ m_data.subpixel, m_data.make, m_data.model, m_data.transform);
+}
+
void Output::sendScale(int factor)
{
Q_ASSERT(m_version >= WL_OUTPUT_SCALE_SINCE_VERSION);
- m_scale = factor;
+ m_data.scale = factor;
const auto resources = resourceMap().values();
- for (auto r: resources)
- wl_output::send_scale(r->handle, factor);
+ for (auto r : resources)
+ sendScale(r);
+}
+
+void Output::sendScale(Resource *resource)
+{
+ Q_ASSERT(m_version >= WL_OUTPUT_SCALE_SINCE_VERSION);
+ // TODO: check resource version as well?
+ wl_output::send_scale(resource->handle, m_data.scale);
}
void Output::sendDone()
{
Q_ASSERT(m_version >= WL_OUTPUT_DONE_SINCE_VERSION);
+ // TODO: check resource version as well?
const auto resources = resourceMap().values();
- for (auto r: resources)
+ for (auto r : resources)
wl_output::send_done(r->handle);
}
void Output::output_bind_resource(QtWaylandServer::wl_output::Resource *resource)
{
+ sendGeometry(resource);
+ send_mode(resource->handle, mode_preferred | mode_current,
+ m_data.mode.resolution.width(), m_data.mode.resolution.height(), m_data.mode.refreshRate);
if (m_version >= WL_OUTPUT_SCALE_SINCE_VERSION)
- wl_output::send_scale(resource->handle, m_scale);
- //TODO: send other required stuff as well
+ sendScale(resource);
+
if (m_version >= WL_OUTPUT_DONE_SINCE_VERSION)
wl_output::send_done(resource->handle);
}
diff --git a/tests/auto/client/shared/coreprotocol.h b/tests/auto/client/shared/coreprotocol.h
index 2fbe9b139..565ae66ae 100644
--- a/tests/auto/client/shared/coreprotocol.h
+++ b/tests/auto/client/shared/coreprotocol.h
@@ -171,20 +171,59 @@ public:
// TODO
};
+struct OutputMode {
+ explicit OutputMode() = default;
+ explicit OutputMode(const QSize &resolution, int refreshRate = 60000)
+ : resolution(resolution), refreshRate(refreshRate)
+ {}
+ QSize resolution = QSize(1920, 1080);
+ int refreshRate = 60000; // In mHz
+ //TODO: flags (they're currently hard-coded)
+
+ // in mm
+ QSize physicalSizeForDpi(int dpi) { return (QSizeF(resolution) * 25.4 / dpi).toSize(); }
+};
+
+struct OutputData {
+ using Subpixel = QtWaylandServer::wl_output::subpixel;
+ using Transform = QtWaylandServer::wl_output::transform;
+ explicit OutputData() = default;
+
+ // for geometry event
+ QPoint position;
+ QSize physicalSize = QSize(0, 0); // means unknown physical size
+ QString make = "Make";
+ QString model = "Model";
+ Subpixel subpixel = Subpixel::subpixel_unknown;
+ Transform transform = Transform::transform_normal;
+
+ int scale = 1; // for scale event
+ OutputMode mode; // for mode event
+};
+
class Output : public Global, public QtWaylandServer::wl_output
{
Q_OBJECT
public:
- explicit Output(CoreCompositor *compositor, int scale = 1, int version = 2)
+ explicit Output(CoreCompositor *compositor, OutputData data = OutputData(), int version = 2)
: QtWaylandServer::wl_output(compositor->m_display, version)
- , m_scale(scale)
+ , m_data(std::move(data))
, m_version(version)
{}
- void sendScale(int factor);
+
+ void send_geometry() = delete;
+ void sendGeometry();
+ void sendGeometry(Resource *resource); // Sends to only one client
+
void send_scale(int32_t factor) = delete;
- void send_scale(struct ::wl_resource *resource, int32_t factor) = delete;
+ void sendScale(int factor);
+ void sendScale(Resource *resource); // Sends current scale to only one client
+
void sendDone();
- int m_scale = 1;
+
+ int scale() const { return m_data.scale; }
+
+ OutputData m_data;
int m_version = 1; // TODO: remove on libwayland upgrade
protected:
diff --git a/tests/auto/client/shared/mockcompositor.cpp b/tests/auto/client/shared/mockcompositor.cpp
index 45d62a153..bb7cd6f46 100644
--- a/tests/auto/client/shared/mockcompositor.cpp
+++ b/tests/auto/client/shared/mockcompositor.cpp
@@ -39,7 +39,8 @@ DefaultCompositor::DefaultCompositor()
// Legacy versions can override in separate tests by removing and adding.
add<WlCompositor>();
add<SubCompositor>();
- add<Output>();
+ auto *output = add<Output>();
+ output->m_data.physicalSize = output->m_data.mode.physicalSizeForDpi(96);
add<Seat>(Seat::capability_pointer);
add<XdgWmBase>();
add<Shm>();
diff --git a/tests/auto/client/shared/mockcompositor.h b/tests/auto/client/shared/mockcompositor.h
index 07366a493..c7ea4d009 100644
--- a/tests/auto/client/shared/mockcompositor.h
+++ b/tests/auto/client/shared/mockcompositor.h
@@ -47,6 +47,7 @@ class DefaultCompositor : public CoreCompositor
public:
explicit DefaultCompositor();
// Convenience functions
+ Output *output(int i = 0) { return getAll<Output>().value(i, nullptr); }
Surface *surface(int i = 0) { return get<WlCompositor>()->m_surfaces.value(i, nullptr); }
XdgSurface *xdgSurface(int i = 0) { return get<XdgWmBase>()->m_xdgSurfaces.value(i, nullptr); }
XdgToplevel *xdgToplevel(int i = 0) { return get<XdgWmBase>()->toplevel(i); }