summary refs log tree commit diff
path: root/pkgs/desktops/plasma-5.5/libkscreen/libkscreen-backend-path.patch
blob: d5797924d2332071340ea8edc6b6c3ce343a2b81 (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
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 460022f..422a708 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,5 +1,7 @@
 include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${QT_INCLUDES})
 
+configure_file(config-libkscreen.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-libkscreen.h)
+
 set(libkscreen_SRCS
     backendloader.cpp
     config.cpp
diff --git a/src/backendloader.cpp b/src/backendloader.cpp
index b93e469..8aebc14 100644
--- a/src/backendloader.cpp
+++ b/src/backendloader.cpp
@@ -16,6 +16,7 @@
  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA       *
  *************************************************************************************/
 
+#include "config-libkscreen.h"
 #include "backendloader.h"
 #include "debug_p.h"
 #include "backends/abstractbackend.h"
@@ -40,55 +41,54 @@ bool BackendLoader::init()
     const QString backend = qgetenv("KSCREEN_BACKEND").constData();
     const QString backendFilter = QString::fromLatin1("KSC_%1*").arg(backend);
 
-    const QStringList paths = QCoreApplication::libraryPaths();
-    Q_FOREACH (const QString &path, paths) {
-        const QDir dir(path + QDir::separator() + QLatin1String("/kf5/kscreen/"),
-                       backendFilter,
-                       QDir::SortFlags(QDir::QDir::NoSort),
-                       QDir::NoDotAndDotDot | QDir::Files);
-        const QFileInfoList finfos = dir.entryInfoList();
-        Q_FOREACH (const QFileInfo &finfo, finfos) {
-            // Skip "Fake" backend unless explicitly specified via KSCREEN_BACKEND
-            if (backend.isEmpty() && finfo.fileName().contains(QLatin1String("KSC_Fake"))) {
-                continue;
-            }
+    QString path = QFile::decodeName(CMAKE_INSTALL_PREFIX "/" PLUGIN_INSTALL_DIR "/");
 
-            // When on X11, skip the QScreen backend, instead use the XRandR backend,
-            // if not specified in KSCREEN_BACKEND
-            if (backend.isEmpty() &&
-                    finfo.fileName().contains(QLatin1String("KSC_QScreen")) &&
-                    QX11Info::isPlatformX11()) {
-                continue;
-            }
+    const QDir dir(path + QDir::separator() + QLatin1String("/kf5/kscreen/"),
+                   backendFilter,
+                   QDir::SortFlags(QDir::QDir::NoSort),
+                   QDir::NoDotAndDotDot | QDir::Files);
+    const QFileInfoList finfos = dir.entryInfoList();
+    Q_FOREACH (const QFileInfo &finfo, finfos) {
+        // Skip "Fake" backend unless explicitly specified via KSCREEN_BACKEND
+        if (backend.isEmpty() && finfo.fileName().contains(QLatin1String("KSC_Fake"))) {
+            continue;
+        }
 
-            // When not on X11, skip the XRandR backend, and fall back to QSCreen
-            // if not specified in KSCREEN_BACKEND
-            if (backend.isEmpty() &&
-                    finfo.fileName().contains(QLatin1String("KSC_XRandR")) &&
-                    !QX11Info::isPlatformX11()) {
-                continue;
-            }
+        // When on X11, skip the QScreen backend, instead use the XRandR backend,
+        // if not specified in KSCREEN_BACKEND
+        if (backend.isEmpty() &&
+                finfo.fileName().contains(QLatin1String("KSC_QScreen")) &&
+                QX11Info::isPlatformX11()) {
+            continue;
+        }
+
+        // When not on X11, skip the XRandR backend, and fall back to QSCreen
+        // if not specified in KSCREEN_BACKEND
+        if (backend.isEmpty() &&
+                finfo.fileName().contains(QLatin1String("KSC_XRandR")) &&
+                !QX11Info::isPlatformX11()) {
+            continue;
+        }
 
-            QPluginLoader loader(finfo.filePath());
-            loader.load();
-            QObject *instance = loader.instance();
-            if (!instance) {
+        QPluginLoader loader(finfo.filePath());
+        loader.load();
+        QObject *instance = loader.instance();
+        if (!instance) {
+            loader.unload();
+            continue;
+        }
+
+        s_backend = qobject_cast< AbstractBackend* >(instance);
+        if (s_backend) {
+            if (!s_backend->isValid()) {
+                qCDebug(KSCREEN) << "Skipping" << s_backend->name() << "backend";
+                delete s_backend;
+                s_backend = 0;
                 loader.unload();
                 continue;
             }
-
-            s_backend = qobject_cast< AbstractBackend* >(instance);
-            if (s_backend) {
-                if (!s_backend->isValid()) {
-                    qCDebug(KSCREEN) << "Skipping" << s_backend->name() << "backend";
-                    delete s_backend;
-                    s_backend = 0;
-                    loader.unload();
-                    continue;
-                }
-                qCDebug(KSCREEN) << "Loading" << s_backend->name() << "backend";
-                return true;
-            }
+            qCDebug(KSCREEN) << "Loading" << s_backend->name() << "backend";
+            return true;
         }
     }
 
diff --git a/src/config-libkscreen.h.cmake b/src/config-libkscreen.h.cmake
new file mode 100644
index 0000000..a99f3d1
--- /dev/null
+++ b/src/config-libkscreen.h.cmake
@@ -0,0 +1,2 @@
+#define CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}"
+#define PLUGIN_INSTALL_DIR "${PLUGIN_INSTALL_DIR}"