Remove duplicated auto backend resolution

Summary:
kwin_wayland now automatically chooses an appropriate backend, such as
DRM, nested wayland or nested X. If nested it will automatically go into
windowed mode regardless of whether --windowed is set and works fine.

Backend choosing logic existed duplicated in older code for kwin_wayland
--windowed, with the subtle unexpected difference that it preferred
running as an X client over running as a wayland cient if both are
present. This simplifies codes and syncs automatic resolution behaviour.

kwin_wayland --windowed with --x11-display  or --wayland-display will
remain the same.

Test Plan:
Ran kwin_wayland with and without --windowed inside another wayland.
Got the same backend chosen
Tested that kwin_wayland (without --windowed) on an X machine worked just fine.

Reviewers: #kwin, mart

Reviewed By: #kwin, mart

Subscribers: mart, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13658
This commit is contained in:
David Edmundson 2018-09-13 10:20:57 +01:00
parent d485dfe7ef
commit 0a2e51db47

View file

@ -560,7 +560,6 @@ int main(int argc, char * argv[])
}
);
};
const bool hasWindowedOption = hasPlugin(KWin::s_x11Plugin) || hasPlugin(KWin::s_waylandPlugin);
const bool hasSizeOption = hasPlugin(KWin::s_x11Plugin) || hasPlugin(KWin::s_virtualPlugin);
const bool hasOutputCountOption = hasPlugin(KWin::s_x11Plugin);
const bool hasX11Option = hasPlugin(KWin::s_x11Plugin);
@ -579,8 +578,6 @@ int main(int argc, char * argv[])
QCommandLineOption waylandSocketOption(QStringList{QStringLiteral("s"), QStringLiteral("socket")},
i18n("Name of the Wayland socket to listen on. If not set \"wayland-0\" is used."),
QStringLiteral("socket"));
QCommandLineOption windowedOption(QStringLiteral("windowed"),
i18n("Use a nested compositor in windowed mode."));
QCommandLineOption framebufferOption(QStringLiteral("framebuffer"),
i18n("Render to framebuffer."));
QCommandLineOption framebufferDeviceOption(QStringLiteral("fb-device"),
@ -616,9 +613,6 @@ int main(int argc, char * argv[])
a.setupCommandLine(&parser);
parser.addOption(xwaylandOption);
parser.addOption(waylandSocketOption);
if (hasWindowedOption) {
parser.addOption(windowedOption);
}
if (hasX11Option) {
parser.addOption(x11DisplayOption);
}
@ -740,25 +734,14 @@ int main(int argc, char * argv[])
}
}
if (hasWindowedOption && parser.isSet(windowedOption)) {
if (hasX11Option && parser.isSet(x11DisplayOption)) {
deviceIdentifier = parser.value(x11DisplayOption).toUtf8();
} else if (!(hasWaylandOption && parser.isSet(waylandDisplayOption))) {
deviceIdentifier = qgetenv("DISPLAY");
}
if (!deviceIdentifier.isEmpty()) {
pluginName = KWin::s_x11Plugin;
} else if (hasWaylandOption) {
if (parser.isSet(waylandDisplayOption)) {
deviceIdentifier = parser.value(waylandDisplayOption).toUtf8();
} else {
deviceIdentifier = qgetenv("WAYLAND_DISPLAY");
}
if (!deviceIdentifier.isEmpty()) {
pluginName = KWin::s_waylandPlugin;
}
}
if (hasX11Option && parser.isSet(x11DisplayOption)) {
deviceIdentifier = parser.value(x11DisplayOption).toUtf8();
pluginName = KWin::s_x11Plugin;
} else if (hasWaylandOption && parser.isSet(waylandDisplayOption)) {
deviceIdentifier = parser.value(waylandDisplayOption).toUtf8();
pluginName = KWin::s_waylandPlugin;
}
if (hasFramebufferOption && parser.isSet(framebufferOption)) {
pluginName = KWin::s_fbdevPlugin;
deviceIdentifier = parser.value(framebufferDeviceOption).toUtf8();