From c6fab6a167bcd3bba4cafe2532c0529ca76b8068 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 7 Mar 2017 00:25:58 -0800 Subject: Get the ping/pong system all setup within the NativeWindowSystem. --- src-qt5/core/libLumina/NativeWindowSystem.cpp | 17 ++++++++++++++++- src-qt5/core/libLumina/NativeWindowSystem.h | 21 +++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'src-qt5/core/libLumina') diff --git a/src-qt5/core/libLumina/NativeWindowSystem.cpp b/src-qt5/core/libLumina/NativeWindowSystem.cpp index 723415f2..c4905d4c 100644 --- a/src-qt5/core/libLumina/NativeWindowSystem.cpp +++ b/src-qt5/core/libLumina/NativeWindowSystem.cpp @@ -173,7 +173,8 @@ public: // === PUBLIC === NativeWindowSystem::NativeWindowSystem() : QObject(){ - obj = 0; + obj = 0; + pingTimer = 0; } NativeWindowSystem::~NativeWindowSystem(){ @@ -491,6 +492,13 @@ void NativeWindowSystem::WindowPropertyChanged(WId id, NativeWindow::Property pr } } +void NativeWindowSystem::GotPong(WId id){ + if(waitingForPong.contains(id)){ + waitingForPong.remove(id); + } + if(waitingForPong.isEmpty() && pingTimer!=0){ pingTimer->stop(); } +} + /*void NativeWindowSystem::NewKeyPress(int keycode, WId win){ emit NewInputEvent(); } @@ -581,5 +589,12 @@ void NativeWindowSystem::RequestKill(WId win){ } void NativeWindowSystem::RequestPing(WId win){ + waitingForPong.insert(win, QDateTime::currentDateTime().addSecs(5) ); xcb_ewmh_send_wm_ping(&obj->EWMH, win, XCB_CURRENT_TIME); + if(pingTimer==0){ + pingTimer = new QTimer(this); + pingTimer->setInterval(2000); //2seconds + connect(pingTimer, SIGNAL(timeout()), this, SLOT(checkPings()) ); + } + pingTimer->start(); } diff --git a/src-qt5/core/libLumina/NativeWindowSystem.h b/src-qt5/core/libLumina/NativeWindowSystem.h index f5d4c8ae..59e54ca4 100644 --- a/src-qt5/core/libLumina/NativeWindowSystem.h +++ b/src-qt5/core/libLumina/NativeWindowSystem.h @@ -12,6 +12,8 @@ #define _LUMINA_NATIVE_WINDOW_SYSTEM_H #include "NativeWindow.h" +#include +#include class NativeWindowSystem : public QObject{ Q_OBJECT @@ -39,6 +41,23 @@ private: class p_objects; p_objects* obj; + //Internal timers/variables for managing pings + QTimer *pingTimer; + QHash waitingForPong; + void checkPings(){ + QDateTime cur = QDateTime::currentDateTime(); + QList waiting = waitingForPong.keys(); + for(int i=0; istop(); } + NativeWindow *win = findWindow(waiting[i]); + if(win==0){ win = findTrayWindow(waiting[i]); } + if(win!=0){ win->emit WindowNotResponding(waiting[i]); } + } + } + } + // Since some properties may be easier to update in bulk // let the native system interaction do them in whatever logical groups are best void UpdateWindowProperties(NativeWindow* win, QList< NativeWindow::Property > props); @@ -77,6 +96,8 @@ public slots: void NewTrayWindowDetected(WId); //will automatically create the new NativeWindow object void WindowCloseDetected(WId); //will update the lists and make changes if needed 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 NewKeyRelease(int keycode, WId win = 0); void NewMousePress(int buttoncode, WId win = 0); -- cgit