Package: kde-workspace / 4:4.11.13-2

plasma_netbook_fix_autostart.diff Patch series | download
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
From: Modestas Vainius <modax@debian.org>
Subject: Fix various problems with autostart of plasma-netbook
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=584905
Last-Update: 2011-03-06

This patch should fully fix problems with startup of plasma-netbook when
plasma-desktop is NOT installed. We aim to support "plasma-desktop"-less
installation via kde-plasma-netbook metapackage hence this bug was a
showstopper for this goal.
Index: kde-workspace/kcontrol/workspaceoptions/workspaceoptions.cpp
===================================================================
--- kde-workspace.orig/kcontrol/workspaceoptions/workspaceoptions.cpp	2013-09-27 09:19:35.568440190 +0000
+++ kde-workspace/kcontrol/workspaceoptions/workspaceoptions.cpp	2013-09-27 09:19:35.560440504 +0000
@@ -92,7 +92,7 @@
 
     m_plasmaNetbookAutostart.setAutostarts(!isDesktop);
     m_plasmaNetbookAutostart.setStartPhase(KAutostart::BaseDesktop);
-    m_plasmaNetbookAutostart.setCommand("plasma-netbook");
+    m_plasmaNetbookAutostart.setCommand("plasma-netbook --desktop");
     m_plasmaNetbookAutostart.setAllowedEnvironments(QStringList()<<"KDE");
 
     m_krunnerAutostart.setAutostarts(isDesktop);
Index: kde-workspace/plasma/netbook/shell/main.cpp
===================================================================
--- kde-workspace.orig/plasma/netbook/shell/main.cpp	2013-09-27 09:19:35.568440190 +0000
+++ kde-workspace/plasma/netbook/shell/main.cpp	2013-09-27 09:19:35.560440504 +0000
@@ -40,10 +40,16 @@
 
 
     bool customGraphicsSystem = false;
+    bool argExplicitDesktop = false;
     for (int i = 0; i < argc; ++i) {
-        if (QString(argv[i]) == "-graphicssystem") {
+        QString arg(argv[i]);
+        if (arg == "-graphicssystem") {
             customGraphicsSystem = true;
             break;
+        } else if (arg == "--desktop") {
+            argExplicitDesktop = true;
+        } else if (arg == "--nodesktop") {
+            argExplicitDesktop = false;
         }
     }
 
@@ -58,9 +64,16 @@
     options.add("nodesktop", ki18n("Starts as a normal application instead of as the primary user interface"));
     options.add("opengl", ki18n("Use OpenGL to draw the main screen"));
     options.add("screen <geometry>", ki18n("The geometry of the screen"), "800x480");
+    if (argExplicitDesktop)
+        options.add("noautostart", ki18n("Explicit --desktop enables autostart handling which may be disabled with this option"));
+    else
+        options.add("autostart", ki18n("Enable autostart handling"));
     KCmdLineArgs::addCmdLineOptions(options);
 
     PlasmaApp *app = PlasmaApp::self();
+    if (!app->shallBeStarted())
+        return 0;
+
     QApplication::setWindowIcon(KIcon("plasma"));
     app->disableSessionManagement(); // autostarted
     int rc = app->exec();
Index: kde-workspace/plasma/netbook/shell/plasmaapp.cpp
===================================================================
--- kde-workspace.orig/plasma/netbook/shell/plasmaapp.cpp	2013-09-27 09:19:35.568440190 +0000
+++ kde-workspace/plasma/netbook/shell/plasmaapp.cpp	2013-09-27 09:19:35.560440504 +0000
@@ -33,6 +33,7 @@
 #include <KStandardAction>
 #include <KWindowSystem>
 #include <KAction>
+#include <KAutostart>
 
 #include <ksmserver_interface.h>
 
@@ -320,7 +321,8 @@
       m_autoHideControlBar(true),
       m_unHideTimer(0),
       m_shadowWindow(0),
-      m_startupSuspendWaitCount(0)
+      m_startupSuspendWaitCount(0),
+      m_shallBeStarted(true)
 {
     PlasmaApp::suspendStartup(true);
     KGlobal::locale()->insertCatalog("libplasma");
@@ -328,6 +330,13 @@
 
 
     KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+    if (args->isSet("autostart")) {
+        setupAutostart();
+        if (!shallBeStarted())
+            return;
+    }
+
     bool isDesktop = args->isSet("desktop");
     if (isDesktop) {
         KCrash::setFlags(KCrash::AutoRestart);
@@ -397,6 +406,38 @@
 {
 }
 
+void PlasmaApp::setupAutostart()
+{
+    // If autostart service is not registered, do not bother setting
+    // autostart up.
+    if (!KAutostart::isServiceRegistered("plasma-netbook"))
+        return;
+
+    if (KAutostart::isServiceRegistered("plasma-desktop")) {
+        // Both plasma-desktop and plasma-netbook are installed, but
+        // plasma-desktop is preferred. Change plasma-netbook autostart
+        // settings according to plasma-desktop status.
+        m_shallBeStarted = !KAutostart("plasma-desktop").autostarts();
+    } else {
+        // If plasma-desktop is not installed, make sure autostart
+        // is enabled
+        m_shallBeStarted = true;
+    }
+
+    KAutostart netbookAutostart("plasma-netbook");
+    if (netbookAutostart.autostarts() != m_shallBeStarted) {
+        netbookAutostart.setAutostarts(m_shallBeStarted);
+        netbookAutostart.setStartPhase(KAutostart::BaseDesktop);
+        netbookAutostart.setCommand("plasma-netbook --desktop");
+        netbookAutostart.setAllowedEnvironments(QStringList()<<"KDE");
+    }
+}
+
+bool PlasmaApp::shallBeStarted()
+{
+    return m_shallBeStarted;
+}
+
 void PlasmaApp::cleanup()
 {
     if (m_corona) {
Index: kde-workspace/plasma/netbook/shell/plasmaapp.h
===================================================================
--- kde-workspace.orig/plasma/netbook/shell/plasmaapp.h	2013-09-27 09:19:35.568440190 +0000
+++ kde-workspace/plasma/netbook/shell/plasmaapp.h	2013-09-27 09:19:35.560440504 +0000
@@ -87,6 +87,12 @@
      */
     bool isDesktop() const;
 
+    /**
+      * Returns false if plasma-netbook should not be started
+      *  (e.g. due to enabled autostart of plasma-desktop)
+      */
+    bool shallBeStarted();
+
     void showWidgetExplorer(Plasma::Containment *containment);
 
 public Q_SLOTS:
@@ -105,6 +111,7 @@
     void reserveStruts();
     void createUnhideTrigger();
     void destroyUnHideTrigger();
+    void setupAutostart();
 
 private Q_SLOTS:
     void cleanup();
@@ -152,6 +159,7 @@
     QTimer *m_unHideTimer;
     ShadowWindow *m_shadowWindow;
     int m_startupSuspendWaitCount;
+    bool m_shallBeStarted;
 };
 
 #endif // multiple inclusion guard
Index: kde-workspace/startkde.cmake
===================================================================
--- kde-workspace.orig/startkde.cmake	2013-09-27 09:19:35.568440190 +0000
+++ kde-workspace/startkde.cmake	2013-09-27 09:19:35.564440346 +0000
@@ -282,6 +282,24 @@
     exit 1
 fi
 
+# Added by Debian to fix bug #584905.
+# Reset user plasma-desktop/plasma-netbook autostart configuration if autostart
+# desktop file is not available system-wide for either of the shells. This
+# ensures that a user does not end up without any autostarted plasma shell when
+# a package of the active shell gets removed.
+if [ ! -e "@AUTOSTART_INSTALL_DIR@/plasma-desktop.desktop" ] && \
+   [ -e "@AUTOSTART_INSTALL_DIR@/plasma-netbook.desktop" ];
+then
+    # Reset custom plasma-netbook configuration
+    user_autostart_dir=`kde4-config --path autostart | cut -d: -f1`
+    rm -f "$user_autostart_dir/plasma-netbook.desktop"
+elif [ -e "@AUTOSTART_INSTALL_DIR@/plasma-desktop.desktop" ] && \
+     [ ! -e "@AUTOSTART_INSTALL_DIR@/plasma-netbook.desktop" ];
+then
+    # Reset custom plasma-desktop configuration
+    user_autostart_dir=`kde4-config --path autostart | cut -d: -f1`
+    rm -f "$user_autostart_dir/plasma-desktop.desktop"
+fi
 
 # Mark that full KDE session is running (e.g. Konqueror preloading works only
 # with full KDE running). The KDE_FULL_SESSION property can be detected by