-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose platform outputs to compositors
Introduce OutputsModel that together with Output can be used from QML to access platform outputs. Compositors will use it to create WaylandOutput instrances for each platform output. Closes: #47
- Loading branch information
Showing
9 changed files
with
309 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// SPDX-FileCopyrightText: 2024 Pier Luigi Fiorini <[email protected]> | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
#include "eglfsdeviceintegration_p.h" | ||
#include "outputsmodel.h" | ||
#include "outputsmodel_p.h" | ||
|
||
namespace Aurora { | ||
|
||
namespace Platform { | ||
|
||
/* | ||
* PlatformOutputsModel | ||
*/ | ||
|
||
OutputsModel::OutputsModel(QObject *parent) | ||
: QAbstractListModel(parent) | ||
, d_ptr(new OutputsModelPrivate(this)) | ||
{ | ||
Q_D(OutputsModel); | ||
|
||
auto *deviceIntegration = auroraDeviceIntegration(); | ||
d->outputs = deviceIntegration->outputs(); | ||
|
||
connect(deviceIntegration, &DeviceIntegration::outputAdded, this, [this, d](Output *output) { | ||
beginInsertRows(QModelIndex(), d->outputs.size(), d->outputs.size()); | ||
d->outputs.append(output); | ||
endInsertRows(); | ||
}); | ||
connect(deviceIntegration, &DeviceIntegration::outputRemoved, this, [this, d](Output *output) { | ||
beginRemoveRows(QModelIndex(), d->outputs.size(), d->outputs.size()); | ||
d->outputs.removeOne(output); | ||
endRemoveRows(); | ||
}); | ||
} | ||
|
||
OutputsModel::~OutputsModel() | ||
{ | ||
} | ||
|
||
QHash<int, QByteArray> OutputsModel::roleNames() const | ||
{ | ||
QHash<int, QByteArray> roles; | ||
roles[OutputRole] = "output"; | ||
return roles; | ||
} | ||
|
||
int OutputsModel::rowCount(const QModelIndex &parent) const | ||
{ | ||
Q_UNUSED(parent); | ||
Q_D(const OutputsModel); | ||
return d->outputs.size(); | ||
} | ||
|
||
QVariant OutputsModel::data(const QModelIndex &index, int role) const | ||
{ | ||
Q_D(const OutputsModel); | ||
|
||
if (index.row() < 0 || index.row() >= d->outputs.size()) | ||
return {}; | ||
|
||
auto *output = d->outputs.at(index.row()); | ||
if (!output) | ||
return {}; | ||
|
||
switch (role) { | ||
case OutputRole: | ||
return QVariant::fromValue(output); | ||
default: | ||
break; | ||
} | ||
|
||
return {}; | ||
} | ||
|
||
/* | ||
* OutputsModelPrivate | ||
*/ | ||
|
||
OutputsModelPrivate::OutputsModelPrivate(OutputsModel *self) | ||
: q_ptr(self) | ||
{ | ||
} | ||
|
||
} // namespace Platform | ||
|
||
} // namespace Aurora |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-FileCopyrightText: 2024 Pier Luigi Fiorini <[email protected]> | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
#pragma once | ||
|
||
#include <QAbstractListModel> | ||
#include <QQmlEngine> | ||
|
||
#include <LiriAuroraPlatform/liriauroraplatformglobal.h> | ||
|
||
namespace Aurora { | ||
|
||
namespace Platform { | ||
|
||
class OutputsModelPrivate; | ||
|
||
class LIRIAURORAPLATFORM_EXPORT OutputsModel : public QAbstractListModel | ||
{ | ||
Q_OBJECT | ||
QML_NAMED_ELEMENT(PlatformOutputsModel) | ||
Q_DECLARE_PRIVATE(OutputsModel) | ||
public: | ||
enum OutputRoles { | ||
OutputRole = Qt::UserRole + 1 | ||
}; | ||
|
||
explicit OutputsModel(QObject *parent = nullptr); | ||
~OutputsModel(); | ||
|
||
QHash<int, QByteArray> roleNames() const override; | ||
|
||
int rowCount(const QModelIndex &parent = QModelIndex()) const override; | ||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; | ||
|
||
private: | ||
QScopedPointer<OutputsModelPrivate> const d_ptr; | ||
}; | ||
|
||
} // namespace Platform | ||
|
||
} // namespace Aurora |
Oops, something went wrong.