summaryrefslogtreecommitdiff
path: root/user/kscreenlocker/optional-wayland.patch
blob: eee3cb10e25bc9a7eb200e88d99ae2b26a036a42 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
--- kscreenlocker-5.12.9/CMakeLists.txt.old	2019-09-10 10:30:52.000000000 +0000
+++ kscreenlocker-5.12.9/CMakeLists.txt	2019-12-29 16:39:31.945860585 +0000
@@ -73,16 +73,16 @@
 
 find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS X11Extras)
 
-find_package(KF5Wayland CONFIG REQUIRED)
+find_package(KF5Wayland)
 set_package_properties(KF5Wayland PROPERTIES
-                       TYPE REQUIRED
-                       PURPOSE "Required for building screenlocker")
+                       TYPE OPTIONAL
+                       PURPOSE "Required for building Wayland screenlocker")
 find_package(WaylandScanner)
 find_package(Wayland 1.3 COMPONENTS Client Server)
 
 set_package_properties(Wayland PROPERTIES
-                       TYPE REQUIRED
-                       PURPOSE "Required for building screenlocker")
+                       TYPE OPTIONAL
+                       PURPOSE "Required for building Wayland screenlocker")
 
 find_package(loginctl)
 set_package_properties(loginctl PROPERTIES
@@ -138,9 +138,7 @@
    interface.cpp
    globalaccel.cpp
    x11locker.cpp
-   waylandlocker.cpp
    logind.cpp
-   waylandserver.cpp
    powermanagement.cpp
    powermanagement_inhibition.cpp
 )
@@ -149,10 +147,20 @@
 kconfig_add_kcfg_files(ksld_SRCS kcfg/kscreensaversettings.kcfgc)
 qt5_add_dbus_interface(ksld_SRCS ${powerdevilpolicyagent_xml} powerdevilpolicyagent)
 
+if(KF5Wayland_FOUND)
+list(APPEND ksld_SRCS
+   waylandlocker.cpp
+   waylandserver.cpp
+)
 ecm_add_wayland_server_protocol(ksld_SRCS
     PROTOCOL protocols/ksld.xml
     BASENAME ksld
 )
+set(OPT_WL_LIBRARIES
+   KF5::WaylandServer
+   Wayland::Server
+)
+endif(KF5Wayland_FOUND)
 
 add_library(KScreenLocker SHARED ${ksld_SRCS})
 
@@ -171,8 +179,7 @@
    ${X11_LIBRARIES}
    XCB::XCB
    XCB::KEYSYMS
-   KF5::WaylandServer
-   Wayland::Server
+   ${OPT_WL_LIBRARIES}
 )
 
 if (X11_Xinput_FOUND)
--- kscreenlocker-5.12.9/ksldapp.cpp.old	2019-09-10 10:30:16.000000000 +0000
+++ kscreenlocker-5.12.9/ksldapp.cpp	2019-12-29 17:00:37.930322855 +0000
@@ -38,9 +38,11 @@
 #include <KNotification>
 #include <KGlobalAccel>
 
+#ifdef WAYLAND_FOUND
 //kwayland
 #include <KWayland/Server/display.h>
 #include <KWayland/Server/clientconnection.h>
+#endif
 
 // Qt
 #include <QAction>
@@ -84,8 +86,10 @@
     , m_lockState(Unlocked)
     , m_lockProcess(NULL)
     , m_lockWindow(NULL)
+#ifdef WAYLAND_FOUND
     , m_waylandServer(new WaylandServer(this))
     , m_waylandDisplay(nullptr)
+#endif  /* WAYLAND_FOUND */
     , m_lockedTimer(QElapsedTimer())
     , m_idleId(0)
     , m_lockGrace(0)
@@ -96,8 +100,12 @@
     , m_greeterEnv(QProcessEnvironment::systemEnvironment())
     , m_powerManagementInhibition(new PowerManagementInhibition(this))
 {
+#ifdef WAYLAND_FOUND
     m_isX11 = QX11Info::isPlatformX11();
     m_isWayland = QCoreApplication::instance()->property("platformName").toString().startsWith( QLatin1String("wayland"), Qt::CaseInsensitive);
+#else
+    m_isX11 = true;
+#endif
 }
 
 KSldApp::~KSldApp()
@@ -215,9 +223,11 @@
     auto finishedSignal = static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished);
     connect(m_lockProcess, finishedSignal, this,
         [this](int exitCode, QProcess::ExitStatus exitStatus) {
+#ifdef WAYLAND_FOUND
             if (m_isWayland && m_waylandDisplay && m_greeterClientConnection) {
                 m_greeterClientConnection->destroy();
             }
+#endif  /* WAYLAND_FOUND */
             if ((!exitCode && exitStatus == QProcess::NormalExit) || s_graceTimeKill || s_logindExit) {
                 // unlock process finished successfully - we can remove the lock grab
                 s_graceTimeKill = false;
@@ -240,7 +250,9 @@
         [this](QProcess::ProcessError error) {
             if (error == QProcess::FailedToStart) {
                 doUnlock();
+#ifdef WAYLAND_FOUND
                 m_waylandServer->stop();
+#endif  /* WAYLAND_FOUND */
                 qCritical() << "Greeter Process not available";
             }
         }
@@ -533,7 +545,9 @@
     m_lockedTimer.invalidate();
     m_greeterCrashedCounter = 0;
     endGraceTime();
+#ifdef WAYLAND_FOUND
     m_waylandServer->stop();
+#endif  /* WAYLAND_FOUND */
     KNotification::event(QStringLiteral("unlocked"),
                          i18n("Screen unlocked"),
                          QPixmap(),
@@ -553,6 +567,7 @@
 {
     QProcessEnvironment env = m_greeterEnv;
 
+#ifdef WAYLAND_FOUND
     if (m_isWayland && m_waylandDisplay) {
         int sx[2];
         if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sx) < 0) {
@@ -576,6 +591,7 @@
             env.insert("WAYLAND_SOCKET", QByteArray::number(socket));
         }
     }
+#endif  /* WAYLAND_FOUND */
     QStringList args;
     if (establishLock == EstablishLock::Immediate) {
         args << QStringLiteral("--immediateLock");
@@ -596,6 +612,7 @@
         env.insert(s_qtQuickBackend, QStringLiteral("software"));
     }
 
+#ifdef WAYLAND_FOUND
     // start the Wayland server
     int fd = m_waylandServer->start();
     if (fd == -1) {
@@ -605,10 +622,13 @@
 
     args << QStringLiteral("--ksldfd");
     args << QString::number(fd);
+#endif  /* WAYLAND_FOUND */
 
     m_lockProcess->setProcessEnvironment(env);
     m_lockProcess->start(QStringLiteral(KSCREENLOCKER_GREET_BIN), args);
+#ifdef WAYLAND_FOUND
     close(fd);
+#endif
 }
 
 void KSldApp::showLockWindow()
@@ -617,9 +637,11 @@
         if (m_isX11) {
             m_lockWindow = new X11Locker(this);
         }
+#ifdef WAYLAND_FOUND
         if (m_isWayland) {
             m_lockWindow = new WaylandLocker(m_waylandDisplay, this);
         }
+#endif  /* WAYLAND_FOUND */
         if (!m_lockWindow) {
             return;
         }
@@ -637,7 +659,9 @@
                 lockScreenShown();
             }
         , Qt::QueuedConnection);
+#ifdef WAYLAND_FOUND
         connect(m_waylandServer, &WaylandServer::x11WindowAdded, m_lockWindow, &AbstractLocker::addAllowedWindow);
+#endif  /* WAYLAND_FOUND */
     }
     m_lockWindow->showLockWindow();
     if (m_isX11) {
@@ -702,12 +726,14 @@
     }
 }
 
+#ifdef WAYLAND_FOUND
 void KSldApp::setWaylandDisplay(KWayland::Server::Display *display)
 {
     if (m_waylandDisplay != display) {
         m_waylandDisplay = display;
     }
 }
+#endif  /* WAYLAND_FOUND */
 
 void KSldApp::lockScreenShown()
 {
@@ -723,9 +749,11 @@
 void KSldApp::setGreeterEnvironment(const QProcessEnvironment &env)
 {
     m_greeterEnv = env;
+#ifdef WAYLAND_FOUND
     if (m_isWayland) {
         m_greeterEnv.insert(QStringLiteral("QT_QPA_PLATFORM"), QStringLiteral("wayland"));
     }
+#endif  /* WAYLAND_FOUND */
 }
 
 bool KSldApp::event(QEvent *event)
--- kscreenlocker-5.12.9/autotests/CMakeLists.txt.old	2019-09-10 10:30:16.000000000 +0000
+++ kscreenlocker-5.12.9/autotests/CMakeLists.txt	2019-12-29 17:16:10.540254516 +0000
@@ -55,6 +55,7 @@
 add_test(ksmserver-x11LockerTest x11LockerTest)
 ecm_mark_as_test(x11LockerTest)
 
+if(KF5Wayland_FOUND)
 #######################################
 # NoScreensTest
 #######################################
@@ -67,3 +68,4 @@
     )
 add_test(ksld-noScreensTest noScreensTest)
 ecm_mark_as_test(noScreensTest)
+endif()
--- kscreenlocker-5.12.9/greeter/greeterapp.cpp.old	2019-09-10 10:30:16.000000000 +0000
+++ kscreenlocker-5.12.9/greeter/greeterapp.cpp	2019-12-29 17:14:57.458241696 +0000
@@ -26,6 +26,7 @@
 #include "lnf_integration.h"
 
 #include <config-kscreenlocker.h>
+#include <config-workspace.h>
 
 // KDE
 #include <KAuthorized>
@@ -40,12 +41,14 @@
 #include <KPackage/Package>
 #include <KPackage/PackageStructure>
 #include <KPackage/PackageLoader>
+#ifdef WAYLAND_FOUND
 // KWayland
 #include <KWayland/Client/connection_thread.h>
 #include <KWayland/Client/event_queue.h>
 #include <KWayland/Client/plasmashell.h>
 #include <KWayland/Client/registry.h>
 #include <KWayland/Client/surface.h>
+#endif
 // Qt
 #include <QClipboard>
 #include <QAbstractNativeEventFilter>
@@ -63,9 +66,11 @@
 #include <QQmlExpression>
 
 #include <QX11Info>
+#ifdef WAYLAND_FOUND
 // Wayland
 #include <wayland-client.h>
 #include <wayland-ksld-client-protocol.h>
+#endif
 // X11
 #include <X11/Xatom.h>
 #include <X11/Xlib.h>
@@ -137,6 +142,7 @@
     }
     qDeleteAll(m_views);
 
+#ifdef WAYLAND_FOUND
     if (m_ksldInterface) {
         org_kde_ksld_destroy(m_ksldInterface);
     }
@@ -148,6 +154,7 @@
         m_ksldConnectionThread->quit();
         m_ksldConnectionThread->wait();
     }
+#endif  /* WAYLAND_FOUND */
 }
 
 Authenticator *UnlockApp::createAuthenticator()
@@ -165,7 +172,10 @@
 
 void UnlockApp::initialize()
 {
+#ifdef WAYLAND_FOUND
     initializeWayland();
+#endif  /* WAYLAND_FOUND */
+
     // set up the request ignore timeout, so that multiple requests to sleep/suspend/shutdown
     // are not processed in quick (and confusing) succession)
     m_resetRequestIgnoreTimer->setSingleShot(true);
@@ -205,6 +215,7 @@
     if (!platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
         return;
     }
+#ifdef WAYLAND_FOUND
     using namespace KWayland::Client;
     auto *c = ConnectionThread::fromApplication(this);
     if (!c) {
@@ -219,6 +230,7 @@
         return;
     }
     m_plasmaShell = r->createPlasmaShell(i.name, i.version, this);
+#endif  /* WAYLAND_FOUND */
 }
 
 void UnlockApp::loadWallpaperPlugin(KQuickAddons::QuickViewSharedEngine *view)
@@ -281,6 +293,7 @@
             }
         }
 
+#ifdef WAYLAND_FOUND
         if (m_ksldInterface) {
             view->create();
             org_kde_ksld_x11window(m_ksldInterface, view->winId());
@@ -294,6 +307,7 @@
                 view->setProperty("plasmaShellSurface", QVariant::fromValue(shellSurface));
             }
         }
+#endif  /* WAYLAND_FOUND */
 
         // engine stuff
         QQmlContext* context = view->engine()->rootContext();
@@ -353,10 +367,14 @@
 
         auto screen = QGuiApplication::screens()[i];
         view->setGeometry(screen->geometry());
+#ifdef WAYLAND_FOUND
         KWayland::Client::PlasmaShellSurface *plasmaSurface = view->property("plasmaShellSurface").value<KWayland::Client::PlasmaShellSurface *>();
         if (plasmaSurface) {
             plasmaSurface->setPosition(view->geometry().topLeft());
         }
+#else
+	void *plasmaSurface = nullptr;
+#endif  /* WAYLAND_FOUND */
         if (auto object = view->property("wallpaperGraphicsObject").value<KDeclarative::QmlObjectSharedEngine*>()) {
             //initialize with our size to avoid as much resize events as possible
             object->completeInitialization({
@@ -370,9 +388,11 @@
                 view,
                 [view, plasmaSurface](const QRect &geo)  {
                     view->setGeometry(geo);
+#ifdef WAYLAND_FOUND
                     if (plasmaSurface) {
                         plasmaSurface->setPosition(view->geometry().topLeft());
                     }
+#endif  /* WAYLAND_FOUND */
                 }
         );
 
@@ -477,6 +497,7 @@
 
 void UnlockApp::suspendToRam()
 {
+#ifdef WAYLAND_FOUND
     if (m_ignoreRequests) {
         return;
     }
@@ -485,11 +506,12 @@
     m_resetRequestIgnoreTimer->start();
 
     org_kde_ksld_suspendSystem(m_ksldInterface);
-
+#endif  /* WAYLAND_FOUND */
 }
 
 void UnlockApp::suspendToDisk()
 {
+#ifdef WAYLAND_FOUND
     if (m_ignoreRequests) {
         return;
     }
@@ -498,6 +520,7 @@
     m_resetRequestIgnoreTimer->start();
 
     org_kde_ksld_hibernateSystem(m_ksldInterface);
+#endif  /* WAYLAND_FOUND */
 }
 
 void UnlockApp::setTesting(bool enable)
@@ -626,7 +649,7 @@
     m_defaultToSwitchUser = defaultToSwitchUser;
 }
 
-
+#ifdef WAYLAND_FOUND
 static void osdProgress(void *data, org_kde_ksld *org_kde_ksld, const char *icon, int32_t percent, const char *text)
 {
     Q_UNUSED(org_kde_ksld)
@@ -657,9 +680,11 @@
     canSuspend,
     canHibernate
 };
+#endif  /* WAYLAND_FOUND */
 
 void UnlockApp::setKsldSocket(int socket)
 {
+#ifdef WAYLAND_FOUND
     using namespace KWayland::Client;
     m_ksldConnection = new ConnectionThread;
     m_ksldConnection->setSocketFd(socket);
@@ -697,6 +722,7 @@
     m_ksldConnection->moveToThread(m_ksldConnectionThread);
     m_ksldConnectionThread->start();
     m_ksldConnection->initConnection();
+#endif  /* WAYLAND_FOUND */
 }
 
 void UnlockApp::osdProgress(const QString &icon, int percent, const QString &additionalText)
--- kscreenlocker-5.12.9/greeter/CMakeLists.txt.old	2019-09-10 10:30:16.000000000 +0000
+++ kscreenlocker-5.12.9/greeter/CMakeLists.txt	2019-12-29 17:29:44.832222068 +0000
@@ -24,10 +24,16 @@
 qt5_add_resources(kscreenlocker_greet_SRCS fallbacktheme.qrc)
 kconfig_add_kcfg_files(kscreenlocker_greet_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../kcfg/kscreensaversettings.kcfgc)
 
+if(KF5Wayland_FOUND)
 ecm_add_wayland_client_protocol(kscreenlocker_greet_SRCS
     PROTOCOL ../protocols/ksld.xml
     BASENAME ksld
 )
+set(OPT_WL_CLI_LIBRARIES
+    KF5::WaylandClient
+    Wayland::Client
+)
+endif()
 
 add_executable(kscreenlocker_greet ${kscreenlocker_greet_SRCS})
 
@@ -43,8 +49,7 @@
                         Qt5::Qml
                         Qt5::X11Extras
                         ${X11_LIBRARIES}
-                        KF5::WaylandClient
-                        Wayland::Client
+                        ${OPT_WL_CLI_LIBRARIES}
                         )
 if(HAVE_SECCOMP)
     target_link_libraries(kscreenlocker_greet Qt5::DBus Seccomp::Seccomp)