diff options
author | Ken Moore <ken@ixsystems.com> | 2017-06-27 08:20:14 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-06-27 08:20:14 -0400 |
commit | 79ed54ff31ed654b953d46987851ce4f572245c2 (patch) | |
tree | b61de25f0ece7cfdb266f396a826b271c47ed0dd | |
parent | Quick fix for the mkport.sh script (diff) | |
download | lumina-79ed54ff31ed654b953d46987851ce4f572245c2.tar.gz lumina-79ed54ff31ed654b953d46987851ce4f572245c2.tar.bz2 lumina-79ed54ff31ed654b953d46987851ce4f572245c2.zip |
Another large batch of re-organization for lumina-desktop-unified.
This gets the new "NativeWindowSystem" and associated Native* classes all integrated (untested)
18 files changed, 209 insertions, 161 deletions
diff --git a/src-qt5/core/libLumina/NativeWindow.h b/src-qt5/core/libLumina/NativeWindow.h index fbdf9e1b..351462bd 100644 --- a/src-qt5/core/libLumina/NativeWindow.h +++ b/src-qt5/core/libLumina/NativeWindow.h @@ -5,8 +5,8 @@ // See the LICENSE file for full details //=========================================== // This is a container object for setting/announcing changes -// in a native window's properties. -// The WM will usually run the "setProperty" function on this object, +// in a native window's properties. +// The WM will usually run the "setProperty" function on this object, // and any other classes/widgets which watch this window can act appropriatly after-the-fact // Non-WM classes should use the "Request" signals to ask the WM to do something, and listen for changes later //=========================================== @@ -59,7 +59,7 @@ public: ~NativeWindow(); WId id(); - QWindow* window(); + QWindow* window(); QVariant property(NativeWindow::Property); void setProperty(NativeWindow::Property, QVariant); @@ -89,7 +89,7 @@ signals: void RequestClose(WId); //Close the window void RequestKill(WId); //Kill the window/app (usually from being unresponsive) void RequestPing(WId); //Verify that the window is still active (such as not closing after a request - + // System Tray Icon Embed/Unembed Requests //void RequestEmbed(WId, QWidget*); //void RequestUnEmbed(WId, QWidget*); diff --git a/src-qt5/core/libLumina/NativeWindow.pri b/src-qt5/core/libLumina/NativeWindow.pri index a5715287..b10e472c 100644 --- a/src-qt5/core/libLumina/NativeWindow.pri +++ b/src-qt5/core/libLumina/NativeWindow.pri @@ -4,9 +4,11 @@ QT *= x11extras LIBS *= -lc -lxcb -lxcb-ewmh -lxcb-icccm -lxcb-image -lxcb-composite -lxcb-damage -lxcb-util -lXdamage SOURCES *= $${PWD}/NativeWindow.cpp \ - $${PWD}/NativeWindowSystem.cpp + $${PWD}/NativeWindowSystem.cpp \ + $${PWD}/NativeEventFilter.cpp HEADERS *= $${PWD}/NativeWindow.h \ - $${PWD}/NativeWindowSystem.h + $${PWD}/NativeWindowSystem.h \ + $${PWD}/NativeEventFilter.h INCLUDEPATH *= $${PWD} diff --git a/src-qt5/core/libLumina/NativeWindowSystem.cpp b/src-qt5/core/libLumina/NativeWindowSystem.cpp index da7f4404..49839a69 100644 --- a/src-qt5/core/libLumina/NativeWindowSystem.cpp +++ b/src-qt5/core/libLumina/NativeWindowSystem.cpp @@ -175,6 +175,7 @@ public: NativeWindowSystem::NativeWindowSystem() : QObject(){ obj = 0; pingTimer = 0; + screenLocked = false; } NativeWindowSystem::~NativeWindowSystem(){ @@ -210,6 +211,8 @@ void NativeWindowSystem::stop(){ //Small simplification functions Qt::Key NativeWindowSystem::KeycodeToQt(int keycode){ + qDebug() << "Try to convert keycode to Qt::Key:" << keycode; + qDebug() << " - Not implemented yet"; return Qt::Key_unknown; } @@ -410,6 +413,10 @@ void NativeWindowSystem::RegisterVirtualRoot(WId){ } +int NativeWindowSystem::currentWorkspace(){ + return 0; +} + //NativeWindowEventFilter interactions void NativeWindowSystem::NewWindowDetected(WId id){ //Make sure this can be managed first @@ -499,54 +506,29 @@ void NativeWindowSystem::GotPong(WId id){ if(waitingForPong.isEmpty() && pingTimer!=0){ pingTimer->stop(); } } -/*void NativeWindowSystem::NewKeyPress(int keycode, WId win){ +void NativeWindowSystem::NewKeyPress(int keycode, WId win){ emit NewInputEvent(); + if(screenLocked){ return; } + emit KeyPressDetected(win, keycode); } void NativeWindowSystem::NewKeyRelease(int keycode, WId win){ emit NewInputEvent(); - //Convert the native button code into a Qt keycode - //Qt::Key key = keycode; //TODO - //emit KeyReleaseDetected( key, win); + if(screenLocked){ return; } + emit KeyReleaseDetected(win, keycode); } void NativeWindowSystem::NewMousePress(int buttoncode, WId win){ emit NewInputEvent(); - //Convert the native button code into a Qt mouse button code - Qt::MouseButton button; - switch(buttoncode){ - case 1: - button = Qt::LeftButton ; break; - case 2: - button = Qt::MiddleButton ; break; - case 3: - button = Qt::RightButton ; break; - case 4: - button = Qt::LeftButton ; break; - default: - return; //Unhandled button - } - emit MousePressDetected(button, win); + if(screenLocked){ return; } + emit MousePressDetected(win, MouseToQt(buttoncode)); } void NativeWindowSystem::NewMouseRelease(int buttoncode, WId win){ emit NewInputEvent(); - //Convert the native button code into a Qt mouse button code - Qt::MouseButton button; - switch(buttoncode){ - case 1: - button = Qt::LeftButton ; break; - case 2: - button = Qt::MiddleButton ; break; - case 3: - button = Qt::RightButton ; break; - case 4: - button = Qt::LeftButton ; break; - default: - return; //Unhandled button - } - emit MouseReleaseDetected(button, win); -}*/ + if(screenLocked){ return; } + emit MouseReleaseDetected(win, MouseToQt(buttoncode)); +} void NativeWindowSystem::CheckDamageID(WId win){ NativeWindow *WIN = findTrayWindow(win); @@ -564,7 +546,9 @@ void NativeWindowSystem::RequestPropertiesChange(WId win, QList<NativeWindow::Pr if(WIN==0){ istraywin = true; WIN = findTrayWindow(win); } if(WIN==0){ return; } //invalid window ID - no longer available //Now make any changes as needed - + // TODO + qDebug() << "Request Properties Changed:" << props << vals; + qDebug() << " - Not implemented yet"; } void NativeWindowSystem::RequestClose(WId win){ diff --git a/src-qt5/core/libLumina/NativeWindowSystem.h b/src-qt5/core/libLumina/NativeWindowSystem.h index 5ac9c288..eb01a460 100644 --- a/src-qt5/core/libLumina/NativeWindowSystem.h +++ b/src-qt5/core/libLumina/NativeWindowSystem.h @@ -62,6 +62,9 @@ private: // let the native system interaction do them in whatever logical groups are best void UpdateWindowProperties(NativeWindow* win, QList< NativeWindow::Property > props); + //Generic private variables + bool screenLocked; + public: enum Property{ None, CurrentWorkspace, Workspaces, VirtualRoots, WorkAreas }; enum MouseButton{NoButton, LeftButton, RightButton, MidButton, BackButton, ForwardButton, TaskButton, WheelUp, WheelDown, WheelLeft, WheelRight}; @@ -84,8 +87,16 @@ public: public slots: //These are the slots which are typically only used by the desktop system itself or the NativeWindowEventFilter + //This is called by the lock screen to keep the NWS aware of the current status + // it is **NOT** the function to call for the user to actually lock the session (that is in the screensaver/lockscreen class) + void ScreenLockChanged(bool lock){ + screenLocked = lock; + } + //RootWindow interactions void RegisterVirtualRoot(WId); + // - Workspaces + int currentWorkspace(); //void GoToWorkspace(int); //void RegisterWorkspaces(QStringList); //Names of workspaces, in ascending order //void RegisterKnownInteractions(); @@ -98,10 +109,10 @@ public slots: void WindowPropertyChanged(WId, NativeWindow::Property); //will rescan the window and update the object as needed void GotPong(WId); -/* void NewKeyPress(int keycode, WId win = 0); + void NewKeyPress(int keycode, WId win = 0); void NewKeyRelease(int keycode, WId win = 0); void NewMousePress(int buttoncode, WId win = 0); - void NewMouseRelease(int buttoncode, WId win = 0);*/ + void NewMouseRelease(int buttoncode, WId win = 0); void CheckDamageID(WId); private slots: @@ -115,10 +126,10 @@ signals: void NewWindowAvailable(NativeWindow*); void NewTrayWindowAvailable(NativeWindow*); void NewInputEvent(); //a mouse or keypress was detected (lock-state independent); - void KeyPressDetected(Qt::Key, WId); //only emitted if lockstate = false - void KeyReleaseDetected(Qt::Key, WId); //only emitted if lockstate = false - void MousePressDetected(Qt::MouseButton, WId); //only emitted if lockstate = false - void MouseReleaseDetected(Qt::MouseButton, WId); //only emitted if lockstate = false + void KeyPressDetected(WId, int); //only emitted if lockstate = false + void KeyReleaseDetected(WId, int); //only emitted if lockstate = false + void MousePressDetected(WId, NativeWindowSystem::MouseButton); //only emitted if lockstate = false + void MouseReleaseDetected(WId, NativeWindowSystem::MouseButton); //only emitted if lockstate = false }; diff --git a/src-qt5/core/libLumina/RootWindow.cpp b/src-qt5/core/libLumina/RootWindow.cpp index b1f740d3..2586ccc2 100644 --- a/src-qt5/core/libLumina/RootWindow.cpp +++ b/src-qt5/core/libLumina/RootWindow.cpp @@ -51,7 +51,7 @@ void RootWindow::updateScreenPixmap(screeninfo *info){ QPixmap raw(info->file); //load the image from file //Now apply the proper aspect ratio as needed if(info->scale == RootWindow::Stretch || info->scale == RootWindow::Full || info->scale == RootWindow::Fit){ - Qt::AspectRatioMode armode = Qt::KeepAspectRatio; + Qt::AspectRatioMode armode = Qt::KeepAspectRatio; if(info->scale == RootWindow::Stretch ){ armode = Qt::IgnoreAspectRatio; } else if(info->scale == RootWindow::Full ){ armode = Qt::KeepAspectRatioByExpanding; } if(raw.height()!=info->area.height() && raw.width() !=info->area.width()){ @@ -60,16 +60,16 @@ void RootWindow::updateScreenPixmap(screeninfo *info){ } //Now calculate offset and draw width/height QRect drawRect(0,0, raw.width(), raw.height()); - if(info->scale == RootWindow::Full ){ + if(info->scale == RootWindow::Full ){ drawRect.moveTo( (info->area.width() - raw.width())/2, (info->area.height() - raw.height())/2 ); }else if(info->scale == RootWindow::Fit ){ - drawRect.moveTo( (info->area.width() - raw.width())/2, (info->area.height() - raw.height())/2 ); + drawRect.moveTo( (info->area.width() - raw.width())/2, (info->area.height() - raw.height())/2 ); }else if(info->scale == RootWindow::Center ){ - drawRect.moveTo( (info->area.width() - raw.width())/2, (info->area.height() - raw.height())/2 ); + drawRect.moveTo( (info->area.width() - raw.width())/2, (info->area.height() - raw.height())/2 ); }else if(info->scale == RootWindow::Tile ){ //Draw the entire area - no offset drawRect.setHeight(info->area.height()); - drawRect.setWidth(info->area.width()); + drawRect.setWidth(info->area.width()); }else if(info->scale == RootWindow::BottomLeft ){ drawRect.moveTo( 0 , info->area.height() - raw.height() ); }else if(info->scale == RootWindow::BottomRight ){ @@ -138,7 +138,7 @@ void RootWindow::ResizeRoot(){ void RootWindow::ChangeWallpaper(QString id, RootWindow::ScaleType scale, QString file){ bool found = false; for(int i=0; i<WALLPAPERS.length() && !found; i++){ - if(WALLPAPERS[i].id == id){ + if(WALLPAPERS[i].id == id){ WALLPAPERS[i].scale = scale; WALLPAPERS[i].file = file; updateScreenPixmap(&WALLPAPERS[i]); @@ -169,7 +169,7 @@ void RootWindow::ChangeWallpaper(QString id, RootWindow::ScaleType scale, QStrin void RootWindow::NewWindow(NativeWindow *win){ RootSubWindow *subwin = 0; for(int i=0; i<WINDOWS.length() && subwin==0; i++){ - if(WINDOWS[i]->id() == win->id()){ subwin = WINDOWS[i]; } + if(WINDOWS[i]->id() == win->id()){ subwin = WINDOWS[i]; } } if(subwin==0){ subwin = new RootSubWindow(this, win); @@ -181,7 +181,7 @@ void RootWindow::NewWindow(NativeWindow *win){ void RootWindow::CloseWindow(WId win){ for(int i=0; i<WINDOWS.length(); i++){ - if(WINDOWS[i]->id() == win){ WINDOWS.takeAt(i)->clientClosed(); break; } + if(WINDOWS[i]->id() == win){ WINDOWS.takeAt(i)->clientClosed(); break; } } } diff --git a/src-qt5/core/libLumina/RootWindow.h b/src-qt5/core/libLumina/RootWindow.h index 0ae248b5..080c4bd1 100644 --- a/src-qt5/core/libLumina/RootWindow.h +++ b/src-qt5/core/libLumina/RootWindow.h @@ -31,7 +31,7 @@ public: RootWindow(); ~RootWindow(); - + void start(); private: @@ -49,7 +49,7 @@ private: //Window Management QList<RootSubWindow*> WINDOWS; - + public slots: void ResizeRoot(); void ChangeWallpaper(QString id, RootWindow::ScaleType scale, QString file); diff --git a/src-qt5/core/lumina-desktop-unified/LSession.cpp b/src-qt5/core/lumina-desktop-unified/LSession.cpp index e511d7ad..c67156c6 100644 --- a/src-qt5/core/lumina-desktop-unified/LSession.cpp +++ b/src-qt5/core/lumina-desktop-unified/LSession.cpp @@ -15,7 +15,9 @@ #endif //Initialize all the global objects to null pointers -EventFilter* Lumina::EFILTER = 0; +NativeWindowSystem* Lumina::NWS = 0; +NativeEventFilter* Lumina::NEF = 0; +//EventFilter* Lumina::EFILTER = 0; LScreenSaver* Lumina::SS = 0; DesktopSettings* Lumina::SETTINGS = 0; //Lumina::WM = 0; @@ -42,32 +44,29 @@ LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lu this->setAttribute(Qt::AA_UseHighDpiPixmaps); //allow pixmaps to be scaled up as well as down //Now initialize the global objects (but do not start them yet) - Lumina::EFILTER = new EventFilter(); //Need the XCB Event filter first + Lumina::NEF = new NativeEventFilter(); + Lumina::NWS = new NativeWindowSystem(); + //Lumina::EFILTER = new EventFilter(); //Need the XCB Event filter first Lumina::SETTINGS = new DesktopSettings(); Lumina::SS = new LScreenSaver(); //Lumina::WM = new LWindowManager(); //Now put the Event Filter into it's own thread to keep things snappy Lumina::EVThread = new QThread(); - Lumina::EFILTER->moveToThread(Lumina::EVThread); + Lumina::NEF->moveToThread(Lumina::EVThread); Lumina::EVThread->start(); Lumina::ROOTWIN = new RootWindow(); Lumina::APPLIST = new XDGDesktopList(0, true); //keep this list up to date Lumina::SHORTCUTS = new LShortcutEvents(); //this can be moved to it's own thread eventually as well - //Setup the basic connections between the shortcuts class and the session itself - connect(Lumina::SHORTCUTS, SIGNAL(StartLogout()), this, SLOT(StartLogout()) ); - connect(Lumina::SHORTCUTS, SIGNAL(StartReboot()), this, SLOT(StartReboot()) ); - connect(Lumina::SHORTCUTS, SIGNAL(StartShutdown()), this, SLOT(StartShutdown()) ); - //Setup the various connections between the global classes - // NOTE: Most of these connections will only become "active" as the global objects get started during the setupSession routine - connect(Lumina::ROOTWIN, SIGNAL(RegisterVirtualRoot(WId)), Lumina::EFILTER, SLOT(RegisterVirtualRoot(WId)) ); - connect(Lumina::EFILTER, SIGNAL(WindowCreated(NativeWindow*)), Lumina::ROOTWIN, SLOT(NewWindow(NativeWindow*)) ); - } //end check for primary process + setupGlobalConnections(); + } //end check for primary process } LSession::~LSession(){ //Clean up the global objects as needed - if(Lumina::EFILTER!=0){ Lumina::EFILTER->deleteLater(); } + if(Lumina::NEF!=0){ Lumina::NEF->deleteLater(); } + if(Lumina::NWS!=0){ Lumina::NWS->deleteLater(); } + //if(Lumina::EFILTER!=0){ Lumina::EFILTER->deleteLater(); } if(Lumina::SS!=0){ Lumina::SS->deleteLater(); } if(Lumina::EVThread!=0){ if(Lumina::EVThread->isRunning()){ Lumina::EVThread->quit(); } @@ -106,35 +105,39 @@ void LSession::setupSession(){ sessionsettings->value("InitLocale/LC_COLLATE","").toString(), \ sessionsettings->value("InitLocale/LC_CTYPE","").toString() ); }*/ - if(DEBUG){ qDebug() << " - Load Localization Files:" << timer->elapsed();} - currTranslator = LUtils::LoadTranslation(this, "lumina-desktop"); + if(DEBUG){ qDebug() << " - Load Localization Files:" << timer->elapsed();} + currTranslator = LUtils::LoadTranslation(this, "lumina-desktop"); if(DEBUG){ qDebug() << " - Start Event Filter:" << timer->elapsed(); } - Lumina::EFILTER->start(); + Lumina::NEF->start(); + if( !Lumina::NWS->start() ){ + qWarning() << "Could not start the Lumina desktop. Is another desktop or window manager running?"; + this->exit(1); + return; + } //use the system settings //Setup the user's lumina settings directory as necessary splash.showScreen("user"); - if(DEBUG){ qDebug() << " - Init User Files:" << timer->elapsed();} + if(DEBUG){ qDebug() << " - Init User Files:" << timer->elapsed();} //checkUserFiles(); //adds these files to the watcher as well //Initialize the internal variables //DESKTOPS.clear(); - + //Start the background system tray splash.showScreen("systray"); - //Initialize the global menus qDebug() << " - Initialize system menus"; splash.showScreen("apps"); if(DEBUG){ qDebug() << " - Populate App List:" << timer->elapsed();} Lumina::APPLIST->updateList(); //appmenu = new AppMenu(); - + splash.showScreen("menus"); //if(DEBUG){ qDebug() << " - Init SettingsMenu:" << timer->elapsed();} //settingsmenu = new SettingsMenu(); //if(DEBUG){ qDebug() << " - Init SystemWindow:" << timer->elapsed();} //sysWindow = new SystemWindow(); - + //Initialize the desktops splash.showScreen("desktop"); if(DEBUG){ qDebug() << " - Init Desktops:" << timer->elapsed(); } @@ -180,7 +183,7 @@ void LSession::setupSession(){ QTimer::singleShot(500, this, SLOT(launchStartupApps()) ); splash.hide(); LSession::processEvents(); - splash.close(); + splash.close(); LSession::processEvents(); //DEBUG: Wait a bit then close down the session //QTimer::singleShot(15000, this, SLOT(StartLogout()) ); @@ -201,7 +204,7 @@ void LSession::CleanupSession(){ bool playaudio = Lumina::SETTINGS->value(DesktopSettings::Session,"PlayLogoutAudio",true).toBool(); if( playaudio ){ playAudioFile(LOS::LuminaShare()+"Logout.ogg"); } //Now perform any other cleanup - Lumina::EFILTER->stop(); + //Lumina::NEF->stop(); //Now wait a moment for things to close down before quitting if(playaudio){ //wait a max of 5 seconds for audio to finish @@ -219,10 +222,60 @@ void LSession::CleanupSession(){ if(QFile::exists("/tmp/.luminastopping")){ QFile::remove("/tmp/.luminastopping"); } } +//================= + +void LSession::setupGlobalConnections(){ + //Setup the various connections between the global classes + // NOTE: Most of these connections will only become "active" as the global objects get started during the setupSession routine + + //Setup the basic connections between the shortcuts class and the session itself + connect(Lumina::SHORTCUTS, SIGNAL(StartLogout()), this, SLOT(StartLogout()) ); + connect(Lumina::SHORTCUTS, SIGNAL(StartReboot()), this, SLOT(StartReboot()) ); + connect(Lumina::SHORTCUTS, SIGNAL(StartShutdown()), this, SLOT(StartShutdown()) ); + + //Root window connections + connect(Lumina::ROOTWIN, SIGNAL(RegisterVirtualRoot(WId)), Lumina::NWS, SLOT(RegisterVirtualRoot(WId)) ); + + //Native Window Class connections + connect(Lumina::NEF, SIGNAL(WindowCreated(WId)), Lumina::NWS, SLOT(NewWindowDetected(WId))); + connect(Lumina::NEF, SIGNAL(WindowDestroyed(WId)), Lumina::NWS, SLOT(WindowCloseDetected(WId))); + connect(Lumina::NEF, SIGNAL(WindowPropertyChanged(WId, NativeWindow::Property)), Lumina::NWS, SLOT(WindowPropertyChanged(WId, NativeWindow::Property))); + connect(Lumina::NEF, SIGNAL(TrayWindowCreated(WId)), Lumina::NWS, SLOT(NewTrayWindowDetected(WId))); + connect(Lumina::NEF, SIGNAL(TrayWindowDestroyed(WId)), Lumina::NWS, SLOT(WindowCloseDetected(WId))); + connect(Lumina::NEF, SIGNAL(PossibleDamageEvent(WId)), Lumina::NWS, SLOT(CheckDamageID(WId))); + connect(Lumina::NEF, SIGNAL(KeyPressed(int, WId)), Lumina::NWS, SLOT(NewKeyPress(int, WId))); + connect(Lumina::NEF, SIGNAL(KeyReleased(int, WId)), Lumina::NWS, SLOT(NewKeyRelease(int, WId))); + connect(Lumina::NEF, SIGNAL(MousePressed(int, WId)), Lumina::NWS, SLOT(NewMousePress(int, WId))); + connect(Lumina::NEF, SIGNAL(MouseReleased(int, WId)), Lumina::NWS, SLOT(NewMouseRelease(int, WId))); + //connect(Lumina::NEF, SIGNAL(MouseMovement(WId)), Lumina::NWS, SLOT()); + //connect(Lumina::NEF, SIGNAL(MouseEnterWindow(WId)), Lumina::NWS, SLOT()); + //connect(Lumina::NEF, SIGNAL(MouseLeaveWindow(WId)), Lumina::NWS, SLOT()); + + //Input Events for ScreenSaver + connect(Lumina::NEF, SIGNAL(KeyPressed(int, WId)), Lumina::SS, SLOT(newInputEvent())); + connect(Lumina::NEF, SIGNAL(KeyReleased(int, WId)), Lumina::SS, SLOT(newInputEvent())); + connect(Lumina::NEF, SIGNAL(MousePressed(int, WId)), Lumina::SS, SLOT(newInputEvent())); + connect(Lumina::NEF, SIGNAL(MouseReleased(int, WId)), Lumina::SS, SLOT(newInputEvent())); + connect(Lumina::NEF, SIGNAL(MouseMovement(WId)), Lumina::SS, SLOT(newInputEvent())); + + connect(Lumina::SS, SIGNAL(LockStatusChanged(bool)), Lumina::NWS, SLOT(ScreenLockChanged(bool)) ); + + //Mouse/Keyboard Shortcut Events (Make sure to connect to the NWS - the raw events need to be ignored sometimes) + connect(Lumina::NWS, SIGNAL(KeyPressDetected(WId, int);), this, SLOT(KeyPress(WId, int)) ); + connect(Lumina::NWS, SIGNAL(KeyReleaseDetected(WId, int)), this, SLOT(KeyRelease(WId, int)) ); + connect(Lumina::NWS, SIGNAL(MousePressDetected(WId, NativeWindowSystem::MouseButton)), this, SLOT(MousePress(WId, NativeWindowSystem::MouseButton)) ); + connect(Lumina::NWS, SIGNAL(MouseReleaseDetected(WId, NativeWindowSystem::MouseButton)), this, SLOT(MouseRelease(WId, NativeWindowSystem::MouseButton)) ); + + //NWS Events to the window system + connect(Lumina::NWS, SIGNAL(NewWindowAvailable(NativeWindow*)), Lumina::ROOTWIN, SLOT(NewWindow(NativeWindow*)) ); +} + +//================= + int LSession::VersionStringToNumber(QString version){ version = version.section("-",0,0); //trim any extra labels off the end int maj, mid, min; //major/middle/minor version numbers (<Major>.<Middle>.<Minor>) - maj = mid = min = 0; + maj = mid = min = 0; bool ok = true; maj = version.section(".",0,0).toInt(&ok); if(ok){ mid = version.section(".",1,1).toInt(&ok); }else{ maj = 0; } @@ -233,6 +286,8 @@ int LSession::VersionStringToNumber(QString version){ return (maj*1000000 + mid*1000 + min); } +//================= + //Play System Audio void LSession::playAudioFile(QString filepath){ if( !QFile::exists(filepath) ){ return; } @@ -257,10 +312,10 @@ void LSession::NewCommunication(QStringList list){ for(int i=0; i<list.length(); i++){ if(list[i]=="--logout"){ QTimer::singleShot(0, this, SLOT(StartLogout()) ); - }else if(list[i]=="--lock-session"){ + }else if(list[i]=="--lock-session"){ Lumina::SS->LockScreenNow(); } - } + } } void LSession::launchStartupApps(){ @@ -275,32 +330,32 @@ void LSession::launchStartupApps(){ QProcess::startDetached("numlockx off"); } } - int tmp = LOS::ScreenBrightness(); - if(tmp>0){ + /*int tmp = LOS::ScreenBrightness(); + if(tmp>0){ LOS::setScreenBrightness( tmp ); qDebug() << " - - Screen Brightness:" << QString::number(tmp)+"%"; } //ExternalProcess::launch("nice lumina-open -autostart-apps"); - + //Re-load the screen brightness and volume settings from the previous session // Wait until after the XDG-autostart functions, since the audio system might be started that way qDebug() << " - Loading previous settings"; tmp = LOS::audioVolume(); LOS::setAudioVolume(tmp); qDebug() << " - - Audio Volume:" << QString::number(tmp)+"%"; - + */ //Now play the login music since we are finished if(Lumina::SETTINGS->value(DesktopSettings::System,"PlayStartupAudio",true).toBool()){ //Make sure to re-set the system volume to the last-used value at outset - int vol = LOS::audioVolume(); - if(vol>=0){ LOS::setAudioVolume(vol); } + /*int vol = LOS::audioVolume(); + if(vol>=0){ LOS::setAudioVolume(vol); }*/ LSession::playAudioFile(LOS::LuminaShare()+"Login.ogg"); } qDebug() << " - Finished with startup routines"; } void LSession::checkUserFiles(){ - //internal version conversion examples: + //internal version conversion examples: // [1.0.0 -> 1000000], [1.2.3 -> 1002003], [0.6.1 -> 6001] QString OVS = Lumina::SETTINGS->value(DesktopSettings::System,"DesktopVersion","0").toString(); //Old Version String bool changed = LDesktopUtils::checkUserFiles(OVS); @@ -322,26 +377,26 @@ void LSession::StartLogout(){ void LSession::StartShutdown(bool skipupdates){ CleanupSession(); LOS::systemShutdown(skipupdates); - QCoreApplication::exit(0); + QCoreApplication::exit(0); } void LSession::StartReboot(bool skipupdates){ CleanupSession(); LOS::systemRestart(skipupdates); - QCoreApplication::exit(0); + QCoreApplication::exit(0); } void LSession::reloadIconTheme(){ //Wait a moment for things to settle before sending out the signal to the interfaces QApplication::processEvents(); QApplication::processEvents(); - emit IconThemeChanged(); + emit IconThemeChanged(); } //Temporarily change the session locale (nothing saved between sessions) void LSession::switchLocale(QString localeCode){ - currTranslator = LUtils::LoadTranslation(this, "lumina-desktop", localeCode, currTranslator); - if(currTranslator!=0 || localeCode=="en_US"){ + currTranslator = LUtils::LoadTranslation(this, "lumina-desktop", localeCode, currTranslator); + if(currTranslator!=0 || localeCode=="en_US"){ LUtils::setLocaleEnv(localeCode); //will set everything to this locale (no custom settings) } emit LocaleChanged(); diff --git a/src-qt5/core/lumina-desktop-unified/LSession.h b/src-qt5/core/lumina-desktop-unified/LSession.h index c791c66b..dd32d22a 100644 --- a/src-qt5/core/lumina-desktop-unified/LSession.h +++ b/src-qt5/core/lumina-desktop-unified/LSession.h @@ -17,7 +17,8 @@ public: private: void CleanupSession(); - + void setupGlobalConnections(); + int VersionStringToNumber(QString version); QMediaPlayer *mediaObj; void playAudioFile(QString filepath); @@ -45,7 +46,7 @@ signals: //General Signals void LocaleChanged(); void IconThemeChanged(); - + }; #endif diff --git a/src-qt5/core/lumina-desktop-unified/global-includes.h b/src-qt5/core/lumina-desktop-unified/global-includes.h index 867076db..53caf88f 100644 --- a/src-qt5/core/lumina-desktop-unified/global-includes.h +++ b/src-qt5/core/lumina-desktop-unified/global-includes.h @@ -59,6 +59,8 @@ #include <RootWindow.h> #include <ExternalProcess.h> #include <NativeWindow.h> +#include <NativeWindowSystem.h> +#include <NativeEventFilter.h> // Standard C includes #include <unistd.h> diff --git a/src-qt5/core/lumina-desktop-unified/global-objects.h b/src-qt5/core/lumina-desktop-unified/global-objects.h index 2f298e27..8d76772e 100644 --- a/src-qt5/core/lumina-desktop-unified/global-objects.h +++ b/src-qt5/core/lumina-desktop-unified/global-objects.h @@ -19,7 +19,7 @@ //Load the appropriate "EventFilter" class for the graphics subsystem //#ifndef USE_WAYLAND -#include "src-events/LXcbEventFilter.h" +//#include "src-events/LXcbEventFilter.h" //#endif #include "src-events/LShortcutEvents.h" @@ -30,9 +30,13 @@ #define ANIMTIME 80 //animation time in milliseconds //Global flags/structures -namespace Lumina{ +namespace Lumina{ //Data structures and objects - extern EventFilter *EFILTER; //Native Event Watcher + // -- Native Window System Objects + extern NativeWindowSystem *NWS; + extern NativeEventFilter *NEF; + + //extern EventFilter *EFILTER; //Native Event Watcher extern LShortcutEvents *SHORTCUTS; //Keyboard/mouse shortcut events extern DesktopSettings *SETTINGS; //All Settings files //ScreenSaver @@ -43,7 +47,7 @@ namespace Lumina{ //LWindowManager *WM; //Application List extern XDGDesktopList *APPLIST; - + extern QThread *EVThread; //X Event thread }; diff --git a/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro b/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro index 1de8308d..58c7e774 100644 --- a/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro +++ b/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro @@ -18,6 +18,7 @@ include(../libLumina/LuminaThemes.pri) include(../libLumina/DesktopSettings.pri) include(../libLumina/RootWindow.pri) include(../libLumina/ExternalProcess.pri) +include(../libLumina/NativeWindow.pri) #include all the main individual source groups include(src-screensaver/screensaver.pri) diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp index e363af01..6bd36ef6 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp @@ -13,7 +13,7 @@ void DesktopContextMenu::SettingsChanged(DesktopSettings::File file){ void DesktopContextMenu::UpdateMenu(){ //Put a label at the top - unsigned int num = Lumina::EFILTER->currentWorkspace(); //LX11::GetCurrentDesktop(); + unsigned int num = Lumina::NWS->currentWorkspace(); workspaceLabel->setText( "<b>"+QString(tr("Workspace %1")).arg(QString::number(num+1))+"</b>"); this->clear(); //clear it for refresh this->addAction(wkspaceact); diff --git a/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.cpp b/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.cpp index b09a1a5b..eb448f02 100644 --- a/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.cpp @@ -25,18 +25,9 @@ void LShortcutEvents::start(){ clearTimer->setSingleShot(true); connect(clearTimer, SIGNAL(timeout()), this, SLOT(clearKeys()) ); } - //Now connect this object to the global EFILTER object signals - connect(Lumina::EFILTER, SIGNAL(KeyPressed(WId, int)), this, SLOT(KeyPress(WId, int)) ); - connect(Lumina::EFILTER, SIGNAL(KeyReleased(WId, int)), this, SLOT(KeyRelease(WId, int)) ); - connect(Lumina::EFILTER, SIGNAL(MousePressed(WId, Lumina::MouseButton)), this, SLOT(MousePress(WId, Lumina::MouseButton)) ); - connect(Lumina::EFILTER, SIGNAL(MouseReleased(WId, Lumina::MouseButton)), this, SLOT(MouseRelease(WId, Lumina::MouseButton)) ); } void LShortcutEvents::stop(){ - disconnect(Lumina::EFILTER, SIGNAL(KeyPressed(WId, int)), this, SLOT(KeyPress(WId, int)) ); - disconnect(Lumina::EFILTER, SIGNAL(KeyReleased(WId, int)), this, SLOT(KeyRelease(WId, int)) ); - disconnect(Lumina::EFILTER, SIGNAL(MousePressed(WId, Lumina::MouseButton)), this, SLOT(MousePress(WId, Lumina::MouseButton)) ); - disconnect(Lumina::EFILTER, SIGNAL(MouseReleased(WId, Lumina::MouseButton)), this, SLOT(MouseRelease(WId, Lumina::MouseButton)) ); clearKeys(); } @@ -59,42 +50,42 @@ void LShortcutEvents::CheckKeySequence(WId win){ } } -void LShortcutEvents::CheckMouseSequence(WId win, Lumina::MouseButton button, bool release){ - if(release && (button == Lumina::WheelUp || button == Lumina::WheelDown || button == Lumina::WheelLeft || button == Lumina::WheelRight)){ +void LShortcutEvents::CheckMouseSequence(WId win, NativeWindowSystem::MouseButton button, bool release){ + if(release && (button == NativeWindowSystem::WheelUp || button == NativeWindowSystem::WheelDown || button == NativeWindowSystem::WheelLeft || button == NativeWindowSystem::WheelRight)){ return; //skip mouse release events for wheel actions (always come in pairs of press/release) - }else if(keylist.isEmpty() || button == Lumina::NoButton){ return; } //Never overwrite mouse clicks themselves - just combinations with key presses + }else if(keylist.isEmpty() || button == NativeWindowSystem::NoButton){ return; } //Never overwrite mouse clicks themselves - just combinations with key presses //Get the keyboard modifiers QString shortcut = keylistToString(); //Add the mouse button to the shortcut switch(button){ - case Lumina::LeftButton: + case NativeWindowSystem::LeftButton: shortcut.append("+LeftMouse"); break; - case Lumina::RightButton: + case NativeWindowSystem::RightButton: shortcut.append("+RightMouse"); break; - case Lumina::MidButton: + case NativeWindowSystem::MidButton: shortcut.append("+MiddleMouse"); break; - case Lumina::BackButton: + case NativeWindowSystem::BackButton: shortcut.append("+BackMouse"); break; - case Lumina::ForwardButton: + case NativeWindowSystem::ForwardButton: shortcut.append("+ForwardMouse"); break; - case Lumina::TaskButton: + case NativeWindowSystem::TaskButton: shortcut.append("+TaskMouse"); break; - case Lumina::WheelUp: + case NativeWindowSystem::WheelUp: shortcut.append("+WheelUp"); break; - case Lumina::WheelDown: + case NativeWindowSystem::WheelDown: shortcut.append("+WheelDown"); break; - case Lumina::WheelLeft: + case NativeWindowSystem::WheelLeft: shortcut.append("+WheelLeft"); break; - case Lumina::WheelRight: + case NativeWindowSystem::WheelRight: shortcut.append("+WheelRight"); break; default: @@ -146,7 +137,7 @@ void LShortcutEvents::evaluateShortcutAction(QString action){ // === PUBLIC SLOTS === void LShortcutEvents::KeyPress(WId window, int key){ if(window!=WIN){ keylist.clear(); WIN = window; } - if(!keylist.contains(key)){ + if(!keylist.contains(key)){ //Put it in the list in ascending order bool found = false; for(int i=0; i<keylist.length() && !found; i++){ @@ -156,26 +147,26 @@ void LShortcutEvents::KeyPress(WId window, int key){ evaluated = false; } //Evaluate the key sequence only when the first one is released - clearTimer->start(); //will "restart" if already running + clearTimer->start(); //will "restart" if already running } void LShortcutEvents::KeyRelease(WId window, int key){ if(window!=WIN){ keylist.clear(); return; } if(!evaluated){ CheckKeySequence(WIN); } //run this "before" removing the key from the list keylist.removeAll(key); - clearTimer->start(); //will "restart" if already running + clearTimer->start(); //will "restart" if already running } -void LShortcutEvents::MousePress(WId window, Lumina::MouseButton button){ +void LShortcutEvents::MousePress(WId window, NativeWindowSystem::MouseButton button){ //We do not provide shortcuts for combinations of mouse buttons - just mouse+keyboard combinations CheckMouseSequence(window, button, false); - clearTimer->start(); //will "restart" if already running + clearTimer->start(); //will "restart" if already running } -void LShortcutEvents::MouseRelease(WId window, Lumina::MouseButton button){ +void LShortcutEvents::MouseRelease(WId window, NativeWindowSystem::MouseButton button){ //We do not provide shortcuts for combinations of mouse buttons - just mouse+keyboard combinations CheckMouseSequence(window, button, true); - clearTimer->start(); //will "restart" if already running + clearTimer->start(); //will "restart" if already running } void LShortcutEvents::clearKeys(){ diff --git a/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.h b/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.h index d1c3b4e0..a8ab4b38 100644 --- a/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.h +++ b/src-qt5/core/lumina-desktop-unified/src-events/LShortcutEvents.h @@ -29,15 +29,15 @@ private: //Actual check functions void CheckKeySequence(WId win); - void CheckMouseSequence(WId win, Lumina::MouseButton, bool release); + void CheckMouseSequence(WId win, NativeWindowSystem::MouseButton, bool release); QString keylistToString(); void evaluateShortcutAction(QString action); public slots: void KeyPress(WId window, int key); void KeyRelease(WId window, int key); - void MousePress(WId window, Lumina::MouseButton); - void MouseRelease(WId window, Lumina::MouseButton); + void MousePress(WId window, NativeWindowSystem::MouseButton); + void MouseRelease(WId window, NativeWindowSystem::MouseButton); void clearKeys(); signals: @@ -50,7 +50,7 @@ signals: // Session Options void ChangeWorkspace(int); // +/- 1 from current void LockSession(); - + //Active Window Options void ActiveWindowMoveToWorkspace(int); //number of workspace void ActiveWindowTakeToWorkspace(int); //number of workspace diff --git a/src-qt5/core/lumina-desktop-unified/src-events/events.pri b/src-qt5/core/lumina-desktop-unified/src-events/events.pri index 9eec91ca..48d500ed 100644 --- a/src-qt5/core/lumina-desktop-unified/src-events/events.pri +++ b/src-qt5/core/lumina-desktop-unified/src-events/events.pri @@ -1,6 +1,6 @@ -SOURCES *= $${PWD}/LXcbEventFilter.cpp +#SOURCES *= $${PWD}/LXcbEventFilter.cpp -HEADERS *= $${PWD}/LXcbEventFilter.h +#HEADERS *= $${PWD}/LXcbEventFilter.h #Shortcut event files SOURCES *= $${PWD}/LShortcutEvents.cpp diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp b/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp index cdcf2434..0ff70142 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LLockScreen.cpp @@ -10,17 +10,15 @@ #include <unistd.h> #define NUMTRIES 3 -//#define WAITMINS 1 #define DEBUG 1 LLockScreen::LLockScreen(QWidget *parent) : QWidget(parent), ui(new Ui::LLockScreen()){ ui->setupUi(this); waittime = new QTimer(this); - //waittime->setInterval(WAITMINS*60000); //(too many attempts in short time) waittime->setSingleShot(true); refreshtime = new QTimer(this); //timer to update the wait time display refreshtime->setInterval(6000); //6 seconds (1/10 second) - + connect(ui->tool_unlock, SIGNAL(clicked()), this, SLOT(TryUnlock()) ); connect(ui->line_password, SIGNAL(returnPressed()), this, SLOT(TryUnlock()) ); connect(ui->line_password, SIGNAL(textEdited(QString)), this, SIGNAL(InputDetected()) ); @@ -30,7 +28,7 @@ LLockScreen::LLockScreen(QWidget *parent) : QWidget(parent), ui(new Ui::LLockScr } LLockScreen::~LLockScreen(){ - + } void LLockScreen::LoadSystemDetails(){ @@ -47,7 +45,7 @@ void LLockScreen::aboutToHide(){ ui->line_password->clear(); ui->line_password->clearFocus(); if(refreshtime->isActive()){ refreshtime->stop(); } -} +} void LLockScreen::aboutToShow(){ if(!waittime->isActive()){ @@ -61,21 +59,17 @@ void LLockScreen::aboutToShow(){ UpdateLockInfo(); ui->line_password->clear(); ui->line_password->setFocus(); -} +} // ================= // PRIVATE SLOTS // ================= void LLockScreen::UpdateLockInfo(){ QString info; - /*if(triesleft>0 && triesleft<NUMTRIES ){ - if(triesleft==1){info = tr("1 Attempt Left"); } - else{info = QString(tr("%1 Attempts Left")).arg(QString::number(triesleft)); } - }else*/ - if(waittime->isActive()){ + if(waittime->isActive()){ info = tr("Too Many Failures")+"\n"+ QString(tr("Wait %1 Minutes")).arg( QString::number(qRound(waittime->remainingTime()/6000.0)/10.0) ); }else if(attempts>0){ info.append("\n"+QString(tr("Failed Attempts: %1")).arg(QString::number(attempts)) ); } - ui->label_info->setText(info); + ui->label_info->setText(info); } void LLockScreen::TryUnlock(){ @@ -89,11 +83,11 @@ void LLockScreen::TryUnlock(){ this->setEnabled(true); }else{ triesleft--; - if(triesleft>0){ + if(triesleft>0){ this->setEnabled(true); - }else{ + }else{ waittime->setInterval( (attempts/NUMTRIES)*60000); - waittime->start(); + waittime->start(); refreshtime->start(); } ui->line_password->setFocus(); diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp index 3dcbf85e..9f280a47 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.cpp @@ -17,7 +17,7 @@ LScreenSaver::LScreenSaver() : QWidget(0,Qt::BypassWindowManagerHint | Qt::Windo locktimer->setSingleShot(true); hidetimer = new QTimer(this); hidetimer->setSingleShot(true); - + LOCKER = new LLockScreen(this); LOCKER->hide(); settings = new QSettings("lumina-desktop","lumina-screensaver",this); @@ -33,7 +33,7 @@ LScreenSaver::LScreenSaver() : QWidget(0,Qt::BypassWindowManagerHint | Qt::Windo } LScreenSaver::~LScreenSaver(){ - + } bool LScreenSaver::isLocked(){ @@ -66,7 +66,7 @@ void LScreenSaver::reloadSettings(){ hidetimer->setInterval( settings->value("hidesecs",15).toInt() * 1000 ); } -void LScreenSaver::newInputEvent(){ +void LScreenSaver::newInputEvent(){ if(updating){ return; } //in the middle of making changes which could cause an event if(DEBUG){ qDebug() << "New Input Event"; } if(SSRunning && SSLocked){ @@ -79,7 +79,6 @@ void LScreenSaver::newInputEvent(){ HideScreenSaver(); } UpdateTimers(); - } void LScreenSaver::LockScreenNow(){ @@ -119,7 +118,7 @@ void LScreenSaver::ShowScreenSaver(){ if(!this->isActiveWindow()){ this->raise(); this->show(); - this->activateWindow(); + this->activateWindow(); } for(int i=0; i<BASES.length(); i++){ BASES[i]->show(); @@ -149,10 +148,11 @@ void LScreenSaver::HideScreenSaver(){ if(!SSLocked){ this->hide(); emit ClosingScreenSaver(); + emit LockStatusChanged(false); } - for(int i=0; i<BASES.length(); i++){ + for(int i=0; i<BASES.length(); i++){ BASES[i]->hide(); - BASES[i]->stopPainting(); + BASES[i]->stopPainting(); } UpdateTimers(); } @@ -171,6 +171,7 @@ void LScreenSaver::LockScreen(){ if(SSLocked){ return; } if(DEBUG){ qDebug() << "Locking Screen:" << QDateTime::currentDateTime().toString(); } SSLocked = true; + emit LockStatusChanged(true); LOCKER->LoadSystemDetails(); UpdateTimers(); } @@ -178,6 +179,7 @@ void LScreenSaver::LockScreen(){ void LScreenSaver::SSFinished(){ if(DEBUG){ qDebug() << "Screensaver Finished:" << QDateTime::currentDateTime().toString(); } SSLocked = false; + emit LockStatusChanged(false); HideLockScreen(); HideScreenSaver(); } diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h index d27db37e..18f12fab 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/LScreenSaver.h @@ -19,7 +19,7 @@ public: ~LScreenSaver(); bool isLocked(); - + private: QTimer *starttimer, *locktimer, *hidetimer; QSettings *settings; @@ -48,6 +48,7 @@ private slots: signals: void StartingScreenSaver(); void ClosingScreenSaver(); + void LockStatusChanged(bool locked); protected: void mouseMoveEvent(QMouseEvent*){ |