Changeset df636dd


Ignore:
Timestamp:
08/07/14 10:59:08 (4 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0.3, releng/10.1
Children:
36f3620, 577fa72
Parents:
ffd14a8
Message:

Re-work how the Lumina session is managed. This allows a number of new features:
1) Have Fluxbox automatically reload its configuration file when it is changed.
2) Automatically create/destroy desktops as screens are added/removed from X.
3) Only a single file system watcher for the desktop configuration file now instead of one per screen.
4) Automatically reload the custom Lumina stylesheet after it is changed.

Location:
lumina/lumina-desktop
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • lumina/lumina-desktop/LDesktop.cpp

    r26dcb04 rdf636dd  
    66//=========================================== 
    77#include "LDesktop.h" 
     8#include "LSession.h" 
    89 
    910LDesktop::LDesktop(int deskNum) : QObject(){ 
     
    3435    bgtimer->setSingleShot(true); 
    3536    connect(bgtimer, SIGNAL(timeout()), this, SLOT(UpdateBackground()) ); 
    36   watcher = new QFileSystemWatcher(this); 
    37     connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(SettingsChanged()) ); 
    38     watcher->addPath(settings->fileName()); 
     37  //watcher = new QFileSystemWatcher(this); 
     38    connect(LSession::instance(), SIGNAL(DesktopConfigChanged()), this, SLOT(SettingsChanged()) ); 
     39    //watcher->addPath(settings->fileName()); 
    3940  
    4041  bgWindow = new QWidget(0); 
     
    6364  delete workspacelabel; 
    6465  delete wkspaceact; 
     66} 
     67 
     68int LDesktop::Screen(){ 
     69  return desktopnumber;  
     70} 
     71 
     72void LDesktop::SystemLogout(){  
     73  LSession::systemWindow();  
    6574} 
    6675 
  • lumina/lumina-desktop/LDesktop.h

    r4d19595 rdf636dd  
    2727#include "LPanel.h" 
    2828#include "Globals.h" 
    29 #include "LSession.h" 
     29#include "AppMenu.h" 
    3030#include "desktop-plugins/LDPlugin.h" 
    3131#include "desktop-plugins/LDPluginContainer.h" 
     
    3838        ~LDesktop(); 
    3939         
     40        int Screen(); //return the screen number this object is managing 
     41 
    4042public slots: 
    41         void SystemLogout(){ LSession::systemWindow(); } 
     43        void SystemLogout(); 
    4244        void SystemTerminal(); 
    4345        void SystemFileManager(); 
     
    6062        QWidgetAction *wkspaceact; 
    6163        QList<LDPlugin*> PLUGINS; 
    62         QFileSystemWatcher *watcher; 
     64        //QFileSystemWatcher *watcher; 
    6365        QString CBG; //current background 
    6466         
  • lumina/lumina-desktop/LPanel.cpp

    r26dcb04 rdf636dd  
    161161  this->update(); 
    162162  this->show(); //make sure the panel is visible now 
     163  //Now go through and send the orientation update signal to each plugin 
     164  for(int i=0; i<PLUGINS.length(); i++){ 
     165    QTimer::singleShot(0,PLUGINS[i], SLOT(OrientationUpdate())); 
     166  } 
    163167} 
    164168 
  • lumina/lumina-desktop/LSession.cpp

    r13152b2 rdf636dd  
    88 
    99//Private/global variables (for static function access) 
    10 WId LuminaSessionTrayID; 
    11 AppMenu *appmenu; 
    12 SettingsMenu *settingsmenu; 
    13 QTranslator *currTranslator; 
     10static WId LuminaSessionTrayID; 
     11static AppMenu *appmenu; 
     12static SettingsMenu *settingsmenu; 
     13static QTranslator *currTranslator; 
    1414 
    1515LSession::LSession(int &argc, char ** argv) : QApplication(argc, argv){ 
     
    2727 
    2828LSession::~LSession(){ 
     29  WM->stopWM(); 
     30  for(int i=0; i<DESKTOPS.length(); i++){ 
     31    delete DESKTOPS[i]; 
     32  } 
     33  delete WM; 
    2934  delete settingsmenu; 
    3035  delete appmenu; 
     36  delete currTranslator; 
    3137} 
    3238 
    3339void LSession::setupSession(){ 
    3440  qDebug() << "Initializing Session"; 
     41 
     42  //Load the stylesheet 
    3543  loadStyleSheet(); 
    3644  //Setup the QSettings default paths 
    3745  QSettings::setPath(QSettings::NativeFormat, QSettings::UserScope, QDir::homePath()+"/.lumina"); 
    38    
    39   checkUserFiles(); //copy/initialize any files necessary 
     46  //Setup the user's lumina settings directory as necessary 
     47  checkUserFiles(); //adds these files to the watcher as well 
     48 
     49  //Initialize the internal variables 
     50  DESKTOPS.clear(); 
    4051         
     52  //Launch Fluxbox 
     53  WM = new WMProcess(); 
     54    WM->startWM(); 
    4155  //Initialize the global menus 
    4256  appmenu = new AppMenu(); 
    4357  settingsmenu = new SettingsMenu(); 
     58 
     59  //Now setup the system watcher for changes 
     60  watcher = new QFileSystemWatcher(this); 
     61    watcher->addPath( QDir::homePath()+"/.lumina/stylesheet.qss" ); 
     62    watcher->addPath( QDir::homePath()+"/.lumina/LuminaDE/desktopsettings.conf" ); 
     63    watcher->addPath( QDir::homePath()+"/.lumina/fluxbox-init" ); 
     64     
     65  //connect internal signals/slots 
     66  connect(this->desktop(), SIGNAL(screenCountChanged(int)), this, SLOT(updateDesktops()) ); 
     67  connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(watcherChange(QString)) ); 
     68  connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(watcherChange(QString)) ); 
     69   
     70  QTimer::singleShot(0,this, SLOT(updateDesktops())); //perform an initial setup of desktops 
    4471} 
    4572 
     
    6390 
    6491void LSession::launchStartupApps(){ 
    65   QString startfile = QDir::homePath()+"/.lumina/startapps"; 
    66   if(!QFile::exists(startfile)){ startfile = "/usr/local/share/Lumina-DE/startapps"; } 
    67   if(!QFile::exists(startfile)){ return; } 
     92  //First start any system-defined startups, then do user defined 
    6893  qDebug() << "Launching startup applications"; 
    69   QFile file(startfile); 
    70   if( file.open(QIODevice::ReadOnly | QIODevice::Text) ){ 
    71     QTextStream in(&file); 
    72     while(!in.atEnd()){ 
    73       QString entry = in.readLine(); 
    74       if(entry.startsWith("#") || entry.isEmpty()){ continue; } 
    75       //Might put other sanity checks here 
    76       QProcess::startDetached(entry); 
    77     } 
    78     file.close(); 
    79   } 
     94  for(int i=0; i<2; i++){ 
     95    QString startfile; 
     96    if(i==0){startfile = "/usr/local/share/Lumina-DE/startapps"; } 
     97    else{ startfile = QDir::homePath()+"/.lumina/startapps"; } 
     98    if(!QFile::exists(startfile)){ continue; } //go to the next 
     99   
     100    QFile file(startfile); 
     101    if( file.open(QIODevice::ReadOnly | QIODevice::Text) ){ 
     102      QTextStream in(&file); 
     103      while(!in.atEnd()){ 
     104        QString entry = in.readLine(); 
     105        if(entry.startsWith("#") || entry.isEmpty()){ continue; } 
     106        //Might put other sanity checks here 
     107        qDebug() << " - Starting Application:" << entry; 
     108        QProcess::startDetached(entry); 
     109      } 
     110      file.close(); 
     111    } 
     112  } 
     113} 
     114 
     115void LSession::watcherChange(QString changed){ 
     116  if(changed.endsWith("desktopsettings.conf")){ emit DesktopConfigChanged(); } 
     117  else if(changed.endsWith("stylesheet.qss")){ loadStyleSheet(); } 
     118  else if(changed.endsWith("fluxbox-init")){ refreshWindowManager(); } 
    80119} 
    81120 
     
    101140      } 
    102141    } 
     142     
    103143  } 
    104144  if(firstrun){ qDebug() << "First time using Lumina!!"; } 
     
    118158      sheet.replace("\n"," "); //make sure there are no newlines 
    119159    this->setStyleSheet(sheet); 
    120   } 
    121    
     160  }   
     161} 
     162 
     163void LSession::refreshWindowManager(){ 
     164  WM->updateWM(); 
     165} 
     166 
     167void LSession::updateDesktops(){ 
     168  QDesktopWidget *DW = this->desktop(); 
     169    for(int i=0; i<DW->screenCount(); i++){ 
     170      bool found = false; 
     171      for(int j=0; j<DESKTOPS.length() && !found; j++){ 
     172        if(DESKTOPS[j]->Screen()==i){ found = true; } 
     173      } 
     174      if(!found){ 
     175        //Start the desktop on the new screen 
     176        qDebug() << " - Start desktop on screen:" << i; 
     177        DESKTOPS << new LDesktop(i); 
     178      } 
     179    } 
     180    //Now go through and make sure to delete any desktops for detached screens 
     181    for(int i=0; i<DESKTOPS.length(); i++){ 
     182      if(DESKTOPS[i]->Screen() >= DW->screenCount()){ 
     183        qDebug() << " - Remove desktop on screen:" << DESKTOPS[i]->Screen(); 
     184        delete DESKTOPS.takeAt(i); 
     185        i--; 
     186      } 
     187    } 
    122188} 
    123189 
  • lumina/lumina-desktop/LSession.h

    r13152b2 rdf636dd  
    1616#include <QSettings> 
    1717#include <QProxyStyle> 
     18#include <QDesktopWidget> 
     19#include <QList> 
    1820 
    1921#include "Globals.h" 
     
    2123#include "SettingsMenu.h" 
    2224#include "SystemWindow.h" 
     25#include "LDesktop.h" 
     26#include "WMProcess.h" 
    2327 
    2428//LibLumina X11 class 
     
    5862        static SettingsMenu* settingsMenu(); 
    5963 
     64private: 
     65        WMProcess *WM; 
     66        QList<LDesktop*> DESKTOPS; 
     67        QFileSystemWatcher *watcher; 
     68 
    6069public slots: 
    6170        void launchStartupApps(); 
    6271 
    6372private slots: 
     73        void watcherChange(QString); 
     74 
    6475        //Internal simplification functions 
    6576        void checkUserFiles(); 
    6677        void loadStyleSheet(); 
     78        void refreshWindowManager(); 
     79        void updateDesktops(); 
    6780 
    6881        //system tray functions 
     
    7487        void WindowListEvent(); 
    7588        void LocaleChanged(); 
     89        void DesktopConfigChanged(); 
    7690         
    7791}; 
  • lumina/lumina-desktop/WMProcess.cpp

    rf71b232 rdf636dd  
    4343} 
    4444 
     45void WMProcess::updateWM(){ 
     46  if(isRunning()){ 
     47    ::kill(this->pid(), SIGUSR2); //send fluxbox the signal to reload it's configuration 
     48  } 
     49} 
    4550// ======================= 
    4651//    PRIVATE FUNCTIONS 
  • lumina/lumina-desktop/WMProcess.h

    rf71b232 rdf636dd  
    1313#include <QDebug> 
    1414 
     15#include <sys/types.h> 
     16#include <signal.h> 
     17 
    1518class WMProcess : public QProcess{ 
    1619        Q_OBJECT 
     
    2124        void startWM(); 
    2225        void stopWM(); 
     26        void updateWM(); 
    2327         
    2428private: 
  • lumina/lumina-desktop/main.cpp

    r130bc0e rdf636dd  
    66//=========================================== 
    77#include <QDebug> 
    8 #include <QApplication> 
     8//#include <QApplication> 
    99#include <QFile> 
    1010#include <QDir> 
    1111#include <QString> 
    1212#include <QTextStream> 
    13 #include <QDesktopWidget> 
    14 #include <QList> 
    15 #include <QDebug> 
     13//#include <QDesktopWidget> 
     14//#include <QList> 
     15//#include <QDebug> 
    1616 
    1717 
    18 #include "WMProcess.h" 
     18//#include "WMProcess.h" 
    1919#include "Globals.h" 
    20 #include "LDesktop.h" 
     20//#include "LDesktop.h" 
    2121#include "LSession.h" 
    2222 
     
    7171    a.setupSession(); 
    7272    //Start up the Window Manager 
    73     qDebug() << " - Start Window Manager"; 
    74     WMProcess WM; 
    75     WM.startWM(); 
     73    //qDebug() << " - Start Window Manager"; 
     74    //WMProcess WM; 
     75    //WM.startWM(); 
    7676    //QObject::connect(&WM, SIGNAL(WMShutdown()), &a, SLOT(exit()) ); 
    7777    //Load the initial translations 
    78     QTranslator translator; 
    79     QLocale mylocale; 
    80     a.LoadLocale(mylocale.name()); 
     78    //QTranslator translator; 
     79    a.LoadLocale(QLocale().name()); 
    8180    //Now start the desktop 
    82     QDesktopWidget DW; 
     81    /*QDesktopWidget DW; 
    8382    QList<LDesktop*> screens; 
    8483    for(int i=0; i<DW.screenCount(); i++){ 
     
    8685      screens << new LDesktop(i); 
    8786      a.processEvents(); 
    88     } 
     87    }*/ 
    8988    //Start launching external applications 
    9089    QTimer::singleShot(1000, &a, SLOT(launchStartupApps()) ); //wait a second first 
    9190    int retCode = a.exec(); 
    92     qDebug() << "Stopping the window manager"; 
    93     WM.stopWM(); 
     91    //qDebug() << "Stopping the window manager"; 
     92    //WM.stopWM(); 
    9493    qDebug() << "Finished Closing Down Lumina"; 
    9594    logfile.close(); 
  • lumina/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp

    r9d0ec76 rdf636dd  
    66//=========================================== 
    77#include "LSysTray.h" 
     8#include "../../LSession.h" 
    89 
    910LSysTray::LSysTray(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ 
  • lumina/lumina-desktop/panel-plugins/systemtray/LSysTray.h

    r9d0ec76 rdf636dd  
    1717 
    1818//Local includes 
    19 #include "../../LSession.h" 
    2019#include "../LPPlugin.h" 
    2120#include "TrayIcon.h" 
  • lumina/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp

    r0e77750 rdf636dd  
    66//=========================================== 
    77#include "LTaskManagerPlugin.h" 
     8#include "../../LSession.h" 
    89 
    910LTaskManagerPlugin::LTaskManagerPlugin(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ 
     
    1617  this->layout()->setContentsMargins(0,0,0,0); 
    1718  QTimer::singleShot(0,this, SLOT(UpdateButtons()) ); //perform an initial sync 
    18   QTimer::singleShot(0,this, SLOT(OrientationUpdate()) ); //setup horizontal/vertical settings 
     19  QTimer::singleShot(100,this, SLOT(OrientationUpdate()) ); //perform an initial sync 
    1920} 
    2021 
  • lumina/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.h

    r0e77750 rdf636dd  
    2323#include "LWinInfo.h" 
    2424#include "../LPPlugin.h" 
    25 #include "../../LSession.h" //keep this last 
    2625 
    2726class LTaskManagerPlugin : public LPPlugin{ 
  • lumina/lumina-desktop/panel-plugins/userbutton/LUserButton.cpp

    r0e77750 rdf636dd  
    66//=========================================== 
    77#include "LUserButton.h" 
     8#include "../../LSession.h" 
    89 
    910LUserButton::LUserButton(QWidget *parent) : QToolButton(parent){ 
  • lumina/lumina-desktop/panel-plugins/userbutton/LUserButton.h

    r0e77750 rdf636dd  
    1818#include <QCoreApplication> 
    1919#include <QToolButton> 
     20#include <QTimer> 
    2021 
    2122// Lumina-desktop includes 
     
    2324#include "../LPPlugin.h" //main plugin widget 
    2425//#include "../LTBWidget.h" //visual plugin button 
    25 #include "../../LSession.h" 
    2626 
    2727// libLumina includes 
Note: See TracChangeset for help on using the changeset viewer.