diff --git a/shell/main.cpp b/shell/main.cpp index b60406ac6..8f78a106f 100644 --- a/shell/main.cpp +++ b/shell/main.cpp @@ -1,165 +1,164 @@ /* * Copyright 2012 Marco Martin * Copyright 2013 Sebastian Kügler * Copyright 2015 David Edmundson * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include #include #include -#include #include #include #include #include "shellcorona.h" #include "standaloneappcorona.h" #include "shellmanager.h" #include "coronatesthelper.h" #include int main(int argc, char *argv[]) { //Plasma scales itself to font DPI //on X, where we don't have compositor scaling, this generally works fine. //also there are bugs on older Qt, especially when it comes to fractional scaling //there's advantages to disabling, and (other than small context menu icons) few advantages in enabling //On wayland, it's different. Everything is simpler as all co-ordinates are in the same co-ordinate system //we don't have fractional scaling on the client so don't hit most the remaining bugs and //even if we don't use Qt scaling the compositor will try to scale us anyway so we have no choice - if (KWindowSystem::isPlatformX11()) { + if (!qEnvironmentVariableIsSet("PLASMA_USE_QT_SCALING")) { qunsetenv("QT_DEVICE_PIXEL_RATIO"); QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); } QQuickWindow::setDefaultAlphaBuffer(true); KLocalizedString::setApplicationDomain("plasmashell"); QApplication app(argc, argv); KQuickAddons::QtQuickSettings::init(); KAboutData aboutData(QStringLiteral("plasmashell"), i18n("Plasma"), QStringLiteral(PROJECT_VERSION), i18n("Plasma Shell"), KAboutLicense::GPL); KAboutData::setApplicationData(aboutData); app.setQuitOnLastWindowClosed(false); app.setWindowIcon(QIcon::fromTheme(QStringLiteral("plasma"))); { QCommandLineParser cliOptions; QCommandLineOption dbgOption(QStringList() << QStringLiteral("d") << QStringLiteral("qmljsdebugger"), i18n("Enable QML Javascript debugger")); QCommandLineOption noRespawnOption(QStringList() << QStringLiteral("n") << QStringLiteral("no-respawn"), i18n("Do not restart plasma-shell automatically after a crash")); QCommandLineOption shellPluginOption(QStringList() << QStringLiteral("p") << QStringLiteral("shell-plugin"), i18n("Force loading the given shell plugin"), QStringLiteral("plugin")); QCommandLineOption standaloneOption(QStringList() << QStringLiteral("a") << QStringLiteral("standalone"), i18n("Load plasmashell as a standalone application, needs the shell-plugin option to be specified")); QCommandLineOption testOption(QStringList() << QStringLiteral("test"), i18n("Enables test mode and specifies the layout javascript file to set up the testing environment"), i18n("file"), QStringLiteral("layout.js")); cliOptions.addOption(dbgOption); cliOptions.addOption(noRespawnOption); cliOptions.addOption(shellPluginOption); cliOptions.addOption(standaloneOption); cliOptions.addOption(testOption); aboutData.setupCommandLine(&cliOptions); cliOptions.process(app); aboutData.processCommandLine(&cliOptions); QGuiApplication::setFallbackSessionManagementEnabled(false); auto disableSessionManagement = [](QSessionManager &sm) { sm.setRestartHint(QSessionManager::RestartNever); }; QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement); QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement); ShellManager::s_fixedShell = cliOptions.value(shellPluginOption); if (!cliOptions.isSet(noRespawnOption) && !cliOptions.isSet(testOption)) { KCrash::setFlags(KCrash::AutoRestart); } if (cliOptions.isSet(testOption)) { const QUrl layoutUrl = QUrl::fromUserInput(cliOptions.value(testOption), {}, QUrl::AssumeLocalFile); if (!layoutUrl.isLocalFile()) { qWarning() << "ensure the layout file is local" << layoutUrl; cliOptions.showHelp(1); } QStandardPaths::setTestModeEnabled(true); QDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)).removeRecursively(); ShellManager::s_testModeLayout = layoutUrl.toLocalFile(); qApp->setProperty("org.kde.KActivities.core.disableAutostart", true); QObject::connect(ShellManager::instance(), &ShellManager::shellChanged, ShellManager::instance(), [layoutUrl]() { new CoronaTestHelper(ShellManager::instance()->corona()); } ); } if (cliOptions.isSet(standaloneOption)) { if (cliOptions.isSet(shellPluginOption)) { ShellManager::s_standaloneOption = true; app.setApplicationName("plasmashell_"+cliOptions.value(shellPluginOption)); app.setQuitOnLastWindowClosed(true); KDBusService service(KDBusService::Unique); //This will not leak, because corona deletes itself on window close new StandaloneAppCorona(cliOptions.value(shellPluginOption)); return app.exec(); } else { cliOptions.showHelp(1); } } } KDBusService service(KDBusService::Unique); QObject::connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, ShellManager::instance(), &QObject::deleteLater); return app.exec(); } diff --git a/startkde/startplasma.cmake b/startkde/startplasma.cmake index 0c0553e1c..5fb146699 100644 --- a/startkde/startplasma.cmake +++ b/startkde/startplasma.cmake @@ -1,190 +1,193 @@ #!/bin/sh # # DEFAULT KDE STARTUP SCRIPT ( @PROJECT_VERSION@ ) # # Boot sequence: # # kdeinit is used to fork off processes which improves memory usage # and startup time. # # * kdeinit starts klauncher first. # * Then kded is started. kded is responsible for keeping the sycoca # database up to date. When an up to date database is present it goes # into the background and the startup continues. # * Then kdeinit starts kcminit. kcminit performs initialisation of # certain devices according to the user's settings # # * Then ksmserver is started which takes control of the rest of the startup sequence # We need to create config folder so we can write startupconfigkeys if [ ${XDG_CONFIG_HOME} ]; then configDir=$XDG_CONFIG_HOME; else configDir=${HOME}/.config; #this is the default, http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html fi [ -r $configDir/startupconfig ] && . $configDir/startupconfig if test "$kcmfonts_general_forcefontdpi" -ne 0; then xrdb -quiet -merge -nocpp <&2 # export our session variables to the Xwayland server xprop -root -f KDE_FULL_SESSION 8t -set KDE_FULL_SESSION true xprop -root -f KDE_SESSION_VERSION 32c -set KDE_SESSION_VERSION 5 # We set LD_BIND_NOW to increase the efficiency of kdeinit. # kdeinit unsets this variable before loading applications. LD_BIND_NOW=true @CMAKE_INSTALL_FULL_LIBEXECDIR_KF5@/start_kdeinit_wrapper --kded +kcminit_startup if test $? -ne 0; then # Startup error echo 'startplasma: Could not start kdeinit5. Check your installation.' 1>&2 test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null xmessage -geometry 500x100 "Could not start kdeinit5. Check your installation." exit 1 fi qdbus org.kde.KSplash /KSplash org.kde.KSplash.setStage kinit # finally, give the session control to the session manager # see kdebase/ksmserver for the description of the rest of the startup sequence # if the KDEWM environment variable has been set, then it will be used as KDE's # window manager instead of kwin. # if KDEWM is not set, ksmserver will ensure kwin is started. # kwrapper5 is used to reduce startup time and memory usage # kwrapper5 does not return useful error codes such as the exit code of ksmserver. # We only check for 255 which means that the ksmserver process could not be # started, any problems thereafter, e.g. ksmserver failing to initialize, # will remain undetected. # If the session should be locked from the start (locked autologin), # lock now and do the rest of the KDE startup underneath the locker. KSMSERVEROPTIONS=" --no-lockscreen" kwrapper5 @CMAKE_INSTALL_FULL_BINDIR@/ksmserver $KDEWM $KSMSERVEROPTIONS if test $? -eq 255; then # Startup error echo 'startplasma: Could not start ksmserver. Check your installation.' 1>&2 test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null xmessage -geometry 500x100 "Could not start ksmserver. Check your installation." fi wait_drkonqi=`kreadconfig5 --file startkderc --group WaitForDrKonqi --key Enabled --default true` if test x"$wait_drkonqi"x = x"true"x ; then # wait for remaining drkonqi instances with timeout (in seconds) wait_drkonqi_timeout=`kreadconfig5 --file startkderc --group WaitForDrKonqi --key Timeout --default 900` wait_drkonqi_counter=0 while qdbus | grep "^[^w]*org.kde.drkonqi" > /dev/null ; do sleep 5 wait_drkonqi_counter=$((wait_drkonqi_counter+5)) if test "$wait_drkonqi_counter" -ge "$wait_drkonqi_timeout" ; then # ask remaining drkonqis to die in a graceful way qdbus | grep 'org.kde.drkonqi-' | while read address ; do qdbus "$address" "/MainApplication" "quit" done break fi done fi echo 'startplasma: Shutting down...' 1>&2 # just in case test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null # Clean up kdeinit5_shutdown unset KDE_FULL_SESSION xprop -root -remove KDE_FULL_SESSION unset KDE_SESSION_VERSION xprop -root -remove KDE_SESSION_VERSION unset KDE_SESSION_UID echo 'startplasma: Done.' 1>&2