Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuring LSM to setup wayland screen name via WAYLAND_DISPLAY_LSM #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions modules/weboscompositor/weboscompositorconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,22 @@ WebOSCompositorConfig::WebOSCompositorConfig()
m_displayCount = 1;
}
m_primaryScreen = QString::fromLatin1(qgetenv("WEBOS_COMPOSITOR_PRIMARY_SCREEN"));
if (Q_UNLIKELY(m_primaryScreen.isEmpty())) {
if (Q_UNLIKELY(m_primaryScreen.isEmpty()))
{
if (m_outputList.size() > 0)
m_primaryScreen = m_outputList[0];
if (Q_UNLIKELY(m_primaryScreen.isEmpty()))
m_primaryScreen = QGuiApplication::primaryScreen()->name();
{
QScreen *primaryScreen = QGuiApplication::primaryScreen();
if (primaryScreen)
{
m_primaryScreen = QGuiApplication::primaryScreen()->name();
}
else
{
qWarning() << "No primary screen returned from QGuiApplication";
}
}
}
QJsonObject primary = m_outputConfigs.value(m_primaryScreen);
if (!primary.isEmpty()) {
Expand Down
24 changes: 16 additions & 8 deletions modules/weboscompositor/weboscorecompositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ WebOSCoreCompositor::WebOSCoreCompositor(ExtensionFlags extensions, const char *
, m_registered(false)
, m_extensionFlags(extensions)
{
setSocketName(socketName);
checkDaemonFiles();

connect(this, &QWaylandCompositor::surfaceRequested, this, [this] (QWaylandClient *client, uint id, int version) {
WebOSSurface *surface = new WebOSSurface();
Expand Down Expand Up @@ -300,7 +300,6 @@ void WebOSCoreCompositor::create()
{
initializeExtensions(m_extensionFlags);
QWaylandCompositor::create();
checkDaemonFiles();
}

void WebOSCoreCompositor::registerWindow(QQuickWindow *window, QString name)
Expand Down Expand Up @@ -391,19 +390,28 @@ void WebOSCoreCompositor::checkDaemonFiles()

QByteArray name(socketName());
// Similar logic as in wl_display_add_socket()
if (name.isEmpty()) {
name = qgetenv("WAYLAND_DISPLAY");
if (name.isEmpty())
{
name = qgetenv("WAYLAND_DISPLAY_LSM");
if (name.isEmpty())
name = "wayland-0";
{
name = qgetenv("WAYLAND_DISPLAY");
}

if (name.isEmpty())
{
qWarning() << "Using default wayland display socket wayland-0";
name = "wayland-0";
}
setSocketName(name);
}

QFileInfo sInfo(QString("%1/%2").arg(xdgDir.constData()).arg(name.data()));
QFileInfo dInfo(sInfo.absoluteDir().absolutePath());
if (QFile::setPermissions(sInfo.absoluteFilePath(),
QFileDevice::ReadOwner | QFileDevice::WriteOwner |
QFileDevice::ReadGroup | QFileDevice::WriteGroup)) {
QFileDevice::ReadOwner | QFileDevice::WriteOwner | QFileDevice::ExeOwner |
QFileDevice::ReadGroup | QFileDevice::WriteGroup | QFileDevice::ExeGroup |
QFileDevice::ReadOther | QFileDevice::WriteOther | QFileDevice::ExeOther)) {
// TODO: Qt doesn't provide a method to chown at the moment
qDebug() << "Setting ownership of" << sInfo.absoluteFilePath() << "using /bin/chown";
QProcess::startDetached("/bin/chown", { QString("%1:%2").arg(dInfo.owner()).arg(dInfo.group()), sInfo.absoluteFilePath() }, "./");
Expand Down Expand Up @@ -538,7 +546,7 @@ void WebOSCoreCompositor::onSurfaceMapped(QWaylandSurface *surface, WebOSSurface

qDebug() << item << "Items in compositor: " << getItems();
emit surfaceMapped(item);
}
}
}

WebOSSurfaceItem* WebOSCoreCompositor::activeSurface()
Expand Down