Branch: master

755776b6 2015-04-08 11:34:07 Timothy Pearson
Ensure kdesktop signal handlers execute in the main GUI thread
M kdesktop/CMakeLists.txt
M kdesktop/krootwm.cc
M kdesktop/krootwm.h
diff --git a/kdesktop/CMakeLists.txt b/kdesktop/CMakeLists.txt
index 743a345..45cc9e9 100644
--- a/kdesktop/CMakeLists.txt
+++ b/kdesktop/CMakeLists.txt
@@ -95,7 +95,7 @@
 tde_add_tdeinit_executable( ${target} AUTOMOC
   SOURCES ${${target}_SRCS}
   LINK
-    kdesktopsettings-static bgnd-static dmctl-static
+    pthread kdesktopsettings-static bgnd-static dmctl-static
     konq-shared tdeutils-shared
     ${XRENDER_LIBRARIES} ${XCURSOR_LIBRARIES} Xext ${DL_LIBRARIES}
     ${XSS_LIBRARIES} ${DBUS_1_TQT_LIBRARIES}
diff --git a/kdesktop/krootwm.cc b/kdesktop/krootwm.cc
index 677c81f..756d0b5 100644
--- a/kdesktop/krootwm.cc
+++ b/kdesktop/krootwm.cc
@@ -77,10 +77,12 @@
   m_helperThread->start();
   m_threadHelperObject = new KRootWmThreadHelperObject;
   m_threadHelperObject->moveToThread(m_helperThread);
+  connect(this, TQT_SIGNAL(initializeHelperThread()), m_threadHelperObject, TQT_SLOT(initializeThread()));
   connect(this, TQT_SIGNAL(terminateHelperThread()), m_threadHelperObject, TQT_SLOT(terminateThread()));
   connect(this, TQT_SIGNAL(asyncLock()), m_threadHelperObject, TQT_SLOT(slotLock()));
   connect(this, TQT_SIGNAL(asyncLockAndDoNewSession()), m_threadHelperObject, TQT_SLOT(lockAndDoNewSession()));
   connect(this, TQT_SIGNAL(asyncSlotSessionActivated(int)), m_threadHelperObject, TQT_SLOT(slotSessionActivated(int)));
+  initializeHelperThread();
 
   s_rootWm = this;
   m_actionCollection = new TDEActionCollection(_desktop, this, "KRootWm::m_actionCollection");
@@ -880,6 +882,16 @@
         }
 }
 
+void KRootWmThreadHelperObject::initializeThread() {
+	// Prevent kdesktop_lock signals from being handled by the wrong (non-GUI) thread
+	sigset_t set;
+	sigemptyset(&set);
+	sigaddset(&set, SIGUSR1);
+	sigaddset(&set, SIGUSR2);
+	sigaddset(&set, SIGTTIN);
+	pthread_sigmask(SIG_BLOCK, &set, NULL);
+}
+
 void KRootWmThreadHelperObject::terminateThread() {
 	TQEventLoop* eventLoop = TQApplication::eventLoop();
 	if (eventLoop) {
diff --git a/kdesktop/krootwm.h b/kdesktop/krootwm.h
index eb6bd9f..0e27001 100644
--- a/kdesktop/krootwm.h
+++ b/kdesktop/krootwm.h
@@ -127,6 +127,7 @@
   void slotLockNNewSession();
 
 signals:
+  void initializeHelperThread();
   void terminateHelperThread();
   void asyncLock();
   void asyncLockAndDoNewSession();
@@ -192,6 +193,7 @@
 	TQ_OBJECT
 
 	public slots:
+		void initializeThread();
 		void terminateThread();
 		void slotLock();
 		void lockAndDoNewSession();
e80c2bae 2015-04-08 15:13:08 Timothy Pearson
Remove external dcop call and associated thread
Fix lockup on lock screen command due to signal race condition
M kdesktop/desktop.cc
M kdesktop/desktop.h
M kdesktop/krootwm.cc
M kdesktop/krootwm.h
M kdesktop/lock/lockprocess.cc
M kdesktop/lock/main.cc
M kdesktop/lockeng.cc
M kdesktop/lockeng.h
M kdesktop/main.cc
diff --git a/kdesktop/desktop.cc b/kdesktop/desktop.cc
index de6873e..2732bff 100644
--- a/kdesktop/desktop.cc
+++ b/kdesktop/desktop.cc
@@ -134,12 +134,14 @@
 KDesktop::WheelDirection KDesktop::m_eWheelDirection = KDesktop::m_eDefaultWheelDirection;
 const char* KDesktop::m_wheelDirectionStrings[2] = { "Forward", "Reverse" };
 
-KDesktop::KDesktop( bool x_root_hack, bool wait_for_kded ) :
+KDesktop::KDesktop( SaverEngine* saver, bool x_root_hack, bool wait_for_kded ) :
     TQWidget( 0L, "desktop", (WFlags)(WResizeNoErase | ( x_root_hack ? (WStyle_Customize | WStyle_NoBorder) : 0)) ),
     KDesktopIface(),
     // those two WStyle_ break kdesktop when the root-hack isn't used (no Dnd)
    startup_id( NULL ), m_waitForKicker(0)
 {
+  m_pSaver = saver;
+
   NETRootInfo i( tqt_xdisplay(), NET::Supported );
   m_wmSupport = i.isSupported( NET::WM2ShowingDesktop );
 
@@ -249,7 +251,7 @@
      if (!m_bInit)
      {
         delete KRootWm::self();
-        KRootWm* krootwm = new KRootWm( this ); // handler for root menu (used by kdesktop on RMB click)
+        KRootWm* krootwm = new KRootWm( m_pSaver, this ); // handler for root menu (used by kdesktop on RMB click)
         keys->setSlot("Lock Session", krootwm, TQT_SLOT(slotLock()));
         keys->updateConnections();
      }
@@ -327,7 +329,7 @@
      {
         m_pIconView->start();
         delete KRootWm::self();
-        KRootWm* krootwm = new KRootWm( this ); // handler for root menu (used by kdesktop on RMB click)
+        KRootWm* krootwm = new KRootWm( m_pSaver, this ); // handler for root menu (used by kdesktop on RMB click)
         keys->setSlot("Lock Session", krootwm, TQT_SLOT(slotLock()));
         keys->updateConnections();
      }
@@ -395,7 +397,7 @@
 
   // Global keys
   keys = new TDEGlobalAccel( TQT_TQOBJECT(this) );
-  (void) new KRootWm( this );
+  (void) new KRootWm( m_pSaver, this );
 
 #include "kdesktopbindings.cpp"
 
diff --git a/kdesktop/desktop.h b/kdesktop/desktop.h
index 6d8015f..c6a208f 100644
--- a/kdesktop/desktop.h
+++ b/kdesktop/desktop.h
@@ -40,6 +40,7 @@
 class KDIconView;
 class Minicli;
 class TDEActionCollection;
+class SaverEngine;
 
 class KRootWidget : public TQObject
 {
@@ -68,7 +69,7 @@
 
   enum WheelDirection { Forward = 0, Reverse };
 
-  KDesktop(bool x_root_hack, bool wait_for_kded );
+  KDesktop(SaverEngine*, bool x_root_hack, bool wait_for_kded );
   ~KDesktop();
 
   // Implementation of the DCOP interface
@@ -196,6 +197,8 @@
   KDIconView *m_pIconView;
   KRootWidget *m_pRootWidget;
 
+  SaverEngine *m_pSaver;
+
   Minicli *m_miniCli;
 
   StartupId* startup_id;
diff --git a/kdesktop/krootwm.cc b/kdesktop/krootwm.cc
index 756d0b5..d12e024 100644
--- a/kdesktop/krootwm.cc
+++ b/kdesktop/krootwm.cc
@@ -60,6 +60,7 @@
 #include "desktop.h"
 #include "kcustommenu.h"
 #include "kdesktopsettings.h"
+#include "lockeng.h"
 
 #include <netwm.h>
 #include <X11/X.h>
@@ -71,21 +72,11 @@
 
 extern TQCString kdesktop_name, kicker_name, twin_name;
 
-KRootWm::KRootWm(KDesktop* _desktop) : TQObject(_desktop), startup(FALSE)
+KRootWm::KRootWm(SaverEngine* _saver, KDesktop* _desktop) : TQObject(_desktop), startup(FALSE)
 {
-  m_helperThread = new TQEventLoopThread;
-  m_helperThread->start();
-  m_threadHelperObject = new KRootWmThreadHelperObject;
-  m_threadHelperObject->moveToThread(m_helperThread);
-  connect(this, TQT_SIGNAL(initializeHelperThread()), m_threadHelperObject, TQT_SLOT(initializeThread()));
-  connect(this, TQT_SIGNAL(terminateHelperThread()), m_threadHelperObject, TQT_SLOT(terminateThread()));
-  connect(this, TQT_SIGNAL(asyncLock()), m_threadHelperObject, TQT_SLOT(slotLock()));
-  connect(this, TQT_SIGNAL(asyncLockAndDoNewSession()), m_threadHelperObject, TQT_SLOT(lockAndDoNewSession()));
-  connect(this, TQT_SIGNAL(asyncSlotSessionActivated(int)), m_threadHelperObject, TQT_SLOT(slotSessionActivated(int)));
-  initializeHelperThread();
-
   s_rootWm = this;
   m_actionCollection = new TDEActionCollection(_desktop, this, "KRootWm::m_actionCollection");
+  m_pSaver = _saver;
   m_pDesktop = _desktop;
   m_bDesktopEnabled = (m_pDesktop->iconView() != 0);
   customMenu1 = 0;
@@ -226,11 +217,6 @@
 
 KRootWm::~KRootWm()
 {
-  terminateHelperThread();
-  m_helperThread->wait();
-  delete m_threadHelperObject;
-  delete m_helperThread;
-
   delete m_actionCollection;
   delete desktopMenu;
   delete windowListMenu;
@@ -838,7 +824,8 @@
 
 
 void KRootWm::slotLock() {
-	asyncLock();
+	m_pSaver->lockScreen();
+	m_pSaver->waitForLockEngage();
 }
 
 
@@ -882,49 +869,10 @@
         }
 }
 
-void KRootWmThreadHelperObject::initializeThread() {
-	// Prevent kdesktop_lock signals from being handled by the wrong (non-GUI) thread
-	sigset_t set;
-	sigemptyset(&set);
-	sigaddset(&set, SIGUSR1);
-	sigaddset(&set, SIGUSR2);
-	sigaddset(&set, SIGTTIN);
-	pthread_sigmask(SIG_BLOCK, &set, NULL);
-}
-
-void KRootWmThreadHelperObject::terminateThread() {
-	TQEventLoop* eventLoop = TQApplication::eventLoop();
-	if (eventLoop) {
-		eventLoop->exit(0);
-	}
-}
-
-void KRootWmThreadHelperObject::slotLock() {
-	// Block here until lock is complete
-	// If this is not done the desktop of the locked session will be shown after VT switch until the lock fully engages!
-	// Force remote call to ensure that blocking is enforced even though this call is being made from inside the kdesktop_name application...
-	// If this is not done DCOP will translate the call into a send and the desktop of the locked session will be shown after VT switch as above
-	system("dcop kdesktop KScreensaverIface lock");
-}
-
-void KRootWmThreadHelperObject::lockAndDoNewSession() {
-	// Block here until lock is complete
-	// If this is not done the desktop of the locked session will be shown after VT switch until the lock fully engages!
-	// Force remote call to ensure that blocking is enforced even though this call is being made from inside the kdesktop_name application...
-	// If this is not done DCOP will translate the call into a send and the desktop of the locked session will be shown after VT switch as above
-	if (system("dcop kdesktop KScreensaverIface lock") == 0) {
-		DM().startReserve();
-	}
-}
-
-void KRootWmThreadHelperObject::slotSessionActivated(int vt) {
-	DM().lockSwitchVT( vt );
-}
-
 void KRootWm::slotSessionActivated( int ent )
 {
     if (ent > 0 && !sessionsMenu->isItemChecked( ent )) {
-        asyncSlotSessionActivated( ent );
+        DM().lockSwitchVT( ent );
 ** Diff limit reached (max: 250 lines) **
a17bfb0b 2015-04-08 15:18:50 Timothy Pearson
Fix lockeng file formatting
M kdesktop/lockeng.cc
M kdesktop/lockeng.h
 ** Diff limit reached (max: 250 lines) **
751c96f9 2015-04-08 15:27:25 Timothy Pearson
Eliminate usleep() loop during kdesktop startup
Do not switch desktops if lock fails to engage
M kdesktop/krootwm.cc
M kdesktop/lockeng.cc
M kdesktop/lockeng.h
 ** Diff limit reached (max: 250 lines) **