Changeset View
Standalone View
ksplash/ksplashqml/splashwindow.cpp
Show All 12 Lines | |||||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU General Public | 14 | * You should have received a copy of the GNU General Public | ||
15 | * License along with this program; if not, write to the | 15 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "splashwindow.h" | 20 | #include "splashwindow.h" | ||
21 | #include "splashapp.h" | ||||
21 | 22 | | |||
22 | #include <QGuiApplication> | 23 | #include <QGuiApplication> | ||
23 | #include <QQmlContext> | 24 | #include <QQmlContext> | ||
24 | #include <QQuickItem> | 25 | #include <QQuickItem> | ||
25 | #include <QKeyEvent> | 26 | #include <QKeyEvent> | ||
26 | #include <QMouseEvent> | 27 | #include <QMouseEvent> | ||
27 | #include <QTimer> | 28 | #include <QTimer> | ||
28 | #include <QStandardPaths> | 29 | #include <QStandardPaths> | ||
29 | #include <QSurfaceFormat> | 30 | #include <QSurfaceFormat> | ||
30 | #include <KSharedConfig> | 31 | #include <KSharedConfig> | ||
31 | #include <KConfigGroup> | 32 | #include <KConfigGroup> | ||
32 | 33 | | |||
33 | #include <KPackage/Package> | 34 | #include <KPackage/Package> | ||
34 | #include <KPackage/PackageLoader> | 35 | #include <KPackage/PackageLoader> | ||
35 | 36 | | |||
37 | #include <KWayland/Client/surface.h> | ||||
38 | #include <KWayland/Client/plasmashell.h> | ||||
39 | #include <KWindowSystem> | ||||
40 | | ||||
36 | SplashWindow::SplashWindow(bool testing, bool window) | 41 | SplashWindow::SplashWindow(bool testing, bool window) | ||
37 | : KQuickAddons::QuickViewSharedEngine(), | 42 | : KQuickAddons::QuickViewSharedEngine(), | ||
38 | m_stage(0), | 43 | m_stage(0), | ||
39 | m_testing(testing), | 44 | m_testing(testing), | ||
40 | m_window(window) | 45 | m_window(window) | ||
41 | { | 46 | { | ||
42 | setColor(Qt::transparent); | 47 | setColor(Qt::transparent); | ||
43 | setDefaultAlphaBuffer(true); | 48 | setDefaultAlphaBuffer(true); | ||
44 | setClearBeforeRendering(true); | 49 | setClearBeforeRendering(true); | ||
45 | setResizeMode(KQuickAddons::QuickViewSharedEngine::SizeRootObjectToView); | 50 | setResizeMode(KQuickAddons::QuickViewSharedEngine::SizeRootObjectToView); | ||
46 | 51 | | |||
47 | if (!m_window) { | 52 | if (!m_window) { | ||
48 | setFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); | 53 | setFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); | ||
49 | } | 54 | } | ||
50 | 55 | | |||
51 | if (!m_testing && !m_window) { | 56 | if (!m_testing && !m_window) { | ||
52 | if (QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive) == 0) { | 57 | if (KWindowSystem::isPlatformX11()) { | ||
53 | // X11 specific hint only on X11 | 58 | // X11 specific hint only on X11 | ||
54 | setFlags(Qt::BypassWindowManagerHint); | 59 | setFlags(Qt::BypassWindowManagerHint); | ||
55 | } else { | 60 | } else if (!KWindowSystem::isPlatformWayland()) { | ||
56 | // on other platforms go fullscreen | 61 | // on other platforms go fullscreen | ||
62 | // on Wayland we cannot go fullscreen due to QTBUG 54883 | ||||
57 | setWindowState(Qt::WindowFullScreen); | 63 | setWindowState(Qt::WindowFullScreen); | ||
58 | } | 64 | } | ||
59 | } | 65 | } | ||
60 | 66 | | |||
61 | if (m_testing && !m_window) { | 67 | if (m_testing && !m_window && !KWindowSystem::isPlatformWayland()) { | ||
62 | setWindowState(Qt::WindowFullScreen); | 68 | setWindowState(Qt::WindowFullScreen); | ||
63 | } | 69 | } | ||
64 | 70 | | |||
65 | //be sure it will be eventually closed | 71 | //be sure it will be eventually closed | ||
66 | //FIXME: should never be stuck | 72 | //FIXME: should never be stuck | ||
67 | QTimer::singleShot(30000, this, &QWindow::close); | 73 | QTimer::singleShot(30000, this, &QWindow::close); | ||
68 | } | 74 | } | ||
69 | 75 | | |||
70 | void SplashWindow::setStage(int stage) | 76 | void SplashWindow::setStage(int stage) | ||
71 | { | 77 | { | ||
72 | m_stage = stage; | 78 | m_stage = stage; | ||
73 | 79 | | |||
74 | rootObject()->setProperty("stage", stage); | 80 | rootObject()->setProperty("stage", stage); | ||
75 | } | 81 | } | ||
76 | 82 | | |||
83 | bool SplashWindow::event(QEvent *e) | ||||
84 | { | ||||
85 | if (e->type() == QEvent::PlatformSurface) { | ||||
86 | if (auto pe = dynamic_cast<QPlatformSurfaceEvent*>(e)) { | ||||
87 | switch (pe->surfaceEventType()) { | ||||
88 | case QPlatformSurfaceEvent::SurfaceCreated: | ||||
89 | setupWaylandIntegration(); | ||||
90 | break; | ||||
91 | case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed: | ||||
92 | delete m_shellSurface; | ||||
93 | m_shellSurface = nullptr; | ||||
94 | break; | ||||
95 | } | ||||
96 | } | ||||
97 | } | ||||
98 | return KQuickAddons::QuickViewSharedEngine::event(e); | ||||
99 | } | ||||
100 | | ||||
77 | void SplashWindow::keyPressEvent(QKeyEvent *event) | 101 | void SplashWindow::keyPressEvent(QKeyEvent *event) | ||
78 | { | 102 | { | ||
79 | KQuickAddons::QuickViewSharedEngine::keyPressEvent(event); | 103 | KQuickAddons::QuickViewSharedEngine::keyPressEvent(event); | ||
80 | if (m_testing && !event->isAccepted() && event->key() == Qt::Key_Escape) { | 104 | if (m_testing && !event->isAccepted() && event->key() == Qt::Key_Escape) { | ||
81 | close(); | 105 | close(); | ||
82 | } | 106 | } | ||
83 | } | 107 | } | ||
84 | 108 | | |||
Show All 21 Lines | 122 | if (oldGeometryEmpty) { | |||
106 | 130 | | |||
107 | const QString theme = QGuiApplication::arguments().at(1); | 131 | const QString theme = QGuiApplication::arguments().at(1); | ||
108 | if (!theme.startsWith(QLatin1String("--"))) { | 132 | if (!theme.startsWith(QLatin1String("--"))) { | ||
109 | package.setPath(theme); | 133 | package.setPath(theme); | ||
110 | } | 134 | } | ||
111 | 135 | | |||
112 | setSource(QUrl::fromLocalFile(package.filePath("splashmainscript"))); | 136 | setSource(QUrl::fromLocalFile(package.filePath("splashmainscript"))); | ||
113 | } | 137 | } | ||
138 | | ||||
139 | if (m_shellSurface) { | ||||
140 | m_shellSurface->setPosition(geometry().topLeft()); | ||||
141 | } | ||||
142 | } | ||||
143 | | ||||
144 | void SplashWindow::setupWaylandIntegration() | ||||
145 | { | ||||
146 | if (m_shellSurface) { | ||||
147 | // already setup | ||||
148 | return; | ||||
149 | } | ||||
150 | if (SplashApp *a = qobject_cast<SplashApp*>(qApp)) { | ||||
ivan: Can this be done differently - the splash is also used as a part of StartActive which is not a… | |||||
graesslin: What's "StartActive"? | |||||
We had a systemd-like startkde replacement in Plasma Active called StartActive, and sebas recently told me that it was agreed it should be revived (no idea ho was in that meeting :) ). And... it is revived. And it shares the code with ksplashqml - the splash is integrated. ivan: We had a systemd-like startkde replacement in Plasma Active called StartActive, and sebas… | |||||
well tricky then. I need to get to the kwayland integration done in KSplashApp. I need a way to get to that. And if it's not using KSplashApp that needs to be done somewhere else. If you have ideas how to solve this problem, please tell. I don't know how start active is working and how it's integrating the code, but as a session controller I would assume it's getting started before the Wayland server is started. So the whole thing becomes mood anyway. Anyway we had so many contenders for replacing ksmserver over the last years that I'm not going to consider hypothetical problems with possible contenders. Sorry. graesslin: well tricky then. I need to get to the kwayland integration done in KSplashApp. I need a way to… | |||||
It is not a ksmserver replacement, just a startkde replacement. You can ignore this for now. Since we are now mostly in bug fixing mode, and 5.8 is LTS, startplasma (startactive) is not going to replace startkde just yet. I'll see what to do about it later then. ivan: It is not a ksmserver replacement, just a startkde replacement.
You can ignore this for now. | |||||
151 | using namespace KWayland::Client; | ||||
152 | PlasmaShell *interface = a->waylandPlasmaShellInterface(); | ||||
153 | if (!interface) { | ||||
154 | return; | ||||
155 | } | ||||
156 | Surface *s = Surface::fromWindow(this); | ||||
157 | if (!s) { | ||||
158 | return; | ||||
159 | } | ||||
160 | m_shellSurface = interface->createSurface(s, this); | ||||
161 | // Use OSD to make it go above all other windows | ||||
162 | // that's the closest we have to the X11 unmanged layer we have on Wayland | ||||
163 | m_shellSurface->setRole(PlasmaShellSurface::Role::OnScreenDisplay); | ||||
164 | m_shellSurface->setPosition(geometry().topLeft()); | ||||
165 | } | ||||
114 | } | 166 | } |
Can this be done differently - the splash is also used as a part of StartActive which is not a SplashApp?